Appcelerator Titanium国际化无法正常工作

时间:2013-04-19 01:37:38

标签: android iphone titanium appcelerator titanium-alloy

这是一个让我发疯的人:

我最近开始研究Appcelerator Titanium。我已经构建了一些小型应用程序,包括正常项目和使用Alloy,所以我至少了解基础知识。

我无法工作的一件事是i18n文件夹/文件。

以下是我的所作所为: - 创建一个"默认项目" - 将文件夹添加到根目录" i18n" - 添加" en"和" es"文件夹到" i18n" - 添加" strings.xml"这两个新文件夹。 - 补充说:

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

两个strings.xml,除了我放的es字符串&#34; ES Welcome TEST&#34;。 - 参考资料 - &gt; app.js我改变了#34;我是Window 1&#34;到L(&#39; welcome_message&#39;) - 跑完应用程序

普通版和合金版只显示空白屏幕。我想让我的合金应用程序运行最多,但据我所知,本地化代码应该在两个应用程序中都相同。在合金中,我可能只需要把它放在风格中。

任何指针都会很棒!我看过其他帖子声称它不起作用,但所有这些都是语法错误或只是设置错误。我已经复制了他们的代码并且有完全相同的问题它没有工作,所以我有一种感觉我错过了新手步骤。

- 这是一些截图,我刚刚创建了一个全新的常规(非合金)项目,添加了上面的代码并尝试使用L(&#39; welcome_message&#39;)没有运气。我尝试在新PC上安装所有东西,以确保我在主计算机上没有搞乱任何东西。 enter image description here enter image description here

2 个答案:

答案 0 :(得分:2)

下面是答案:

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

默认情况下,默认情况下不会设置清单文件以允许本地化,除非您选择选项卡式项目。

如果你问我,有点傻。

答案 1 :(得分:0)

主题海报:

我的新string.xml文件:

<?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>

我的非合金实验的屏幕截图:

enter image description here

对于那些希望回答主题中的问题的人,可以在下面找到答案。

我的i18n文件夹与app和plugins位于同一层次结构级别,因此我的应用程序文件夹不在Alloy资源的其余部分。

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>

当我将L(“welcome_message”)放在index.xml中时,它不起作用。