rockswang / haxe-i18n

Macro driven internationalization/localization toolkit for Haxe
24 stars 4 forks source link

Using it with stablexui, String has no field i18n #1

Closed hopewise closed 10 years ago

hopewise commented 10 years ago

Although I put: import com.roxstudio.i18n.I18n;

and in constructor of entry main class:

I18n.init();

and for compilation options:

--macro com.roxstudio.i18n.I18n.locale('en')

I got this error:

ui/index.xml:388: characters 24-36 : String has no field i18n

I am using stablexui, here is how I've used it:

<?xml version="1.0" encoding="UTF-8" ?>
<VBox name="'resistor'" w="200" heightPt="100" align    = "'left,top'">
        <Text defaults="'Default,H1'" text="'Hello'.i18n()"/>
</VBox>

here is my en/strings.xml

<strings>
    <t id="Hello">Hello</t>
</strings>

Any example please about using it stablexui? Thanks for great work!

rockswang commented 10 years ago

You need to use "using" instead of "import" to enable mix-in syntax e.g. "Hello".i18n(), it's equivalent to I18n.i18n("Hello"). See http://haxe.org/manual/using for details. rox-i18n works well with StablexUI, here's a real-world example (a snippet from my project):

<Button defaults="'MenuButtons'" text="'remove'.i18n()" />
hopewise commented 10 years ago

I am sorry, I found that I have to say 'using' instead of import. Although it compiles now, but the localization didn't happen, text won't change .. I put compilerflag name="--macro com.roxstudio.i18n.I18n.locale('en')"

in my app nmml file, but, the text won't get localized .. only the text in the widget will appear ..

Any idea please?

hopewise commented 10 years ago

ops, I am sorry, again its my fault, I have to put the folder next to assets, it was in src folder, thanks again.