I18n and Typescript?

I18n and Typescript?
0.0 0

#1

Hi, has anybody successfully integrated the i18n creator library with Typescript? Is there any tutorial/example?
@slackmoehrle @pandamicro?


#2

I am not sure.


#3

Which i18n library you are referring to? The extension https://github.com/cocos-creator-packages/i18n or this https://github.com/cocos-creator/i18n-example?


#4

this one:

Here you can find the english version: Creator game - i18N docs?


#5

You can use it as it is by doing this:

In your .ts file do such import:

import * as i18n from '../i18nPath/i18n';

Use it as usual:

i18n.init ('zh'); // init parameter is the language identifier, such as 'zh', 'en', etc.
var myLocalizedText = i18n.t ('TEXT_KEY');

The only downside is you probably won’t get any autocomplete from i18n.


#6

Hi @jake72 this is exactly what I did and it didnt work. But it was my fault (im starting with Typescript and had an issue with the import syntax). Now it works.
Thanks!