When Should Use Of I18N In Application?

Hi all

I’m developing an application that have one languege. but, I want to using Yii::t() to manage message in one file(for example protected/messages/fa).

my questions are :

1- "when should use of i18n in application?"

2- "Can I use Yii::t() just for site that have one languege to manage esealy message in code?"

3- "Is this practice has affect performance of site?"

tanks :)

1- "when should use of i18n in application?"

When it is nessesar to have multilingual messages

2- "Can I use Yii::t() just for site that have one languege to manage esealy message in code?"

what did you mean? give an example!

3- "Is this practice has affect performance of site?"

Yes slow down the performance, however you could use cache system

for example http://www.yiiframework.com/doc/api/1.1/CFileCache

hi

tanks for your reply :)

for example in protected/message/default.php





<?php


return array(

' cannot be blank' => '...',


);

?>




and in all models :





  public function rules() {


        return array(

            array('username,password', 'required','on' => 'create',

                'message' => Yii::t('default','cannot be blank'),




so, when i going to edit messages, I just may need to edit file in "protected/message/default" instead edit all models or other files. In addition,I can easealy switch to another language or multiple language if necessary.

Nevertheless,I think this practice is Inappropriate. beacuse of slow down the performance and extra overhead.what’s your opinion? :huh:

Hi @za_al

I use your approach in my application, so you could use in most cases!

A full translated site slow down the performance, so you could use cache to solve this problem.

Also to improve the performance you could use

  1. for static pages you could use different files like that

protected/views/site/index.php

protected/views/site/el/index.php

protected/views/site/fe/index.php



  1. for many translated texts you could split on partitions

create more one files like default.php, users.php, anotherpart.php and use


Yii::t('default','...'),

Yii::t('users','...'),

Yii::t('anotherpart','...'),

Thank both by share your impressions.

I am studing the better way to do the I18N by Yii.

Firstly, I studied the Internationalization by Yii at the same site (yiiframework).

I like the idea of how Yii help with I18N. It creates duplicate php files one for every folder associated to locale language (like KonApaz example number one)

The question is, ¿how do I resolved the cache problems? That this method slows down the load page, is sure.

Secondly, I studied the I18N the "gettext php translation" go with the POedit tool to create .po and .mo.

It is a good idea to because the duplicate files are plan text which will be loaded over view files in a fast way more.

But even though resolve the slowing down cache, this have another problem with cache and the replacement the text inside this.

Thanks in advance. :D