Internationalization (I18N)


Where could I find more information about using Internationalization (I18N)?

I got confused about some classes calls like (CLocale)



@qiang : Please give some example on how to use CLocale.



What kind of examples are you expecting?

my current project using YII is writed in portugues, but users of the system use: spanish english and portugues, how is the standard to work in this case

also where I can change the source language

pt_BR example ? is in the configuration file?


and the spected language



This has nothing to do with CLocale. You need to set 'sourceLanguage' to be 'pt' in app config. You can set 'language' in init() of base controller class depending on GET parameter or user cookie setting.

@qiang : All my forms and datagrids show unformatted numeric and date, I want them to be formated, how can I achieved that using locale ?


First get the date formatter corresponding to the currently used locale (determined by 'language' property):


Then check CDateFormatter API documentation on how to make use of the formatter.

Number formatter can be used similarly.

@giang : I tried in one of the form and it works ! since my application have many date and numeric field spread all over in many forms and list, so I think it will be much efficient and easy to manage if I store all formatter in one file. The problem is I'm not sure how to make it centralize, could you please give some hints ?



You could create some global functions for this purpose. They return the needed formatter. You then include these global functions in your entry script file.