Question

Here's one that's driving me crazy:

I have recently started looking into Appcelerator Titanium. I have built a few small apps both with a normal project and using Alloy so I understand the basics at least.

One thing I just cannot get working is the i18n folder/files.

Here is what ive done: - Create a "Default Project" - add folder to root directory "i18n" - add "en" and "es" folder to "i18n" - add "strings.xml" to both those new folders. - added:

    <?xml version="1.0" encoding="UTF-8"?>
    <resources>
       <string name="welcome_message">Welcome TEST</string>
    </resources>

to both the strings.xml, except in the es strings I put "ES Welcome TEST". - In Resources -> app.js I changed "I am Window 1" to L('welcome_message') - Ran the application

Both the normal and alloy versions just show a blank screen. I would like to get my alloy app working the most but from what I understand the localization code should work the same in both apps. In alloy I may just have to put it in the style.

Any pointers would be great! I have looked at other post claiming its not working but all of them were either syntax errors or just set it up wrong. I have copied their code and have the exact same issue with it not working so I have a feeling im missing a newbie step.

-- Here are some screenshots, I just created a brand new regular(not alloy) project, added the code above and try to use L('welcome_message') to no luck. I tried installing everything on a new PC to make sure I wasn't messing anything up on my main computer. enter image description here enter image description here

Was it helpful?

Solution

Heres the answer:

https://wiki.appcelerator.org/display/guides/Internationalization

Ends up by default your manifest file is not setup by default to allow localization UNLESS you choose a tabbed project.

Kinda silly if you ask me.

OTHER TIPS

For the topic poster:

My new string.xml file:

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="welcome_message">Don't Help Austin</string>
    <string name="user_agent_message">user agent set to</string>
    <string name="format_test">Your name is %s</string>
    <string name="base_ui_title">Base UI</string>
    <string name="controls_win_title">Controls</string>
    <string name="phone_win_title">Phone</string>
    <string name="platform_win_title">Platform</string>
    <string name="mashups_win_title">Mashups</string>
    <string name="ordered">Hi %1$s, my name is %2$s</string>
</resources>

Screenshot of my non-Alloy experiment:

enter image description here

For those looking to answer the question in the topic, this is a possible answer below.

My i18n folder is on the same hierarchy level as app and plugins, so mine isn't inside the app folder like the rest of the Alloy resources.

index.xml

<Alloy>
    <Window class="container">
        <Label id="label" onClick="doClick"></Label>
    </Window>
</Alloy>

index.tss

".container": {
    backgroundColor:"white"
},
"Label": {
    width: Ti.UI.SIZE,
    height: Ti.UI.SIZE,
    color: "#000",
    text: L("welcome_message")
} 

strings.xml

<?xml version="1.0" encoding="UTF-8"?>
<resources>
    <string name="welcome_message">Welcome to Kitchen Sink for Titanium</string>
    <string name="user_agent_message">user agent set to</string>
    <string name="format_test">Your name is %s</string>
    <string name="base_ui_title">Base UI</string>
    <string name="controls_win_title">Controls</string>
    <string name="phone_win_title">Phone</string>
    <string name="platform_win_title">Platform</string>
    <string name="mashups_win_title">Mashups</string>
    <string name="ordered">Hi %1$s, my name is %2$s</string>
</resources>

When I placed the L("welcome_message") inside the index.xml, it didn't work.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top