0

I have an android app that I want to internationalise.

I have extracted the app strings and deployed them in resource files and all that works fine.

The remaining issue I have is that my app reads a folder structure and actually pulls filenames in as words to use in the app.

I have these filenames/words defined in my xml, but I can't figure out how to dynamically lookup the english language word.

So. here's the scenario.

Filename = hello.png. I want the word "hello" to appear in my app corresponding to the image; I have the word "hello" defined in my strings.xml and the corresponding language files as "hello_file" (i.e. the word "hello" can be accessed by R.string.hello_file). What I think I need to do is take the english word from the filename and do a reverse lookup on the strings.xml file and find the node corresponding to that and then lookup the corresponding word in the strings_xx.xml file for the iso language translations.

But I don't know how to do that...

Perhaps I'm over complicating this? It does not seem an ideal use case for the strings_xx.xml translation facility.

Any other ideas?

4

1 回答 1

0

使用字符串数组http://developer.android.com/guide/topics/resources/string-resource.html#StringArray

String[] files = getResources().getStringArray(R.array.file_names);

在代码中,您可以遍历所有值以找到您需要的值。

于 2012-06-24T22:13:32.957 回答