Android localization (invalid resource directory name) - android

Each time I create values_enu folder under res folder in eclipse for localization issue I get an error invalid resource directory name
http://developer.android.com/training/basics/supporting-devices/languages.html
Can someone help please.

One thing that wasn't clear to me from the docs is what a directory should be called in case of language variants, e.g. British/American English or German/Austrian German.
So even though the locales are of form en_GB, en_US, de_DE or de_AT etc, the corresponding folders should be called
res/values-en-rGB/
res/values-en-rUS/
res/values-de-rDE/
res/values-de-rAT/
That means keep the letter capitalization but use only hyphens instead of underscores and add an r before the language variant.

Use hyphen(-) instead of underscores(_)..
values-en is valid and values_en is invalid

You only should write "values-en".
The syntax is: FOLDERNAME MINUS 2-CHARACTER-LANGUAGE-KEY
Another example:
drawable-es <<= this will create a folder for Spanish picture files. It could be useful for implementing a labeled button you have created in photoshop or gimp.

Related

Why do I keep getting this "is translated but not found in default local"?

Why do I keep getting this "is translated but not found in default local"? how can I solve it?
To my knowledge there are only two strings files I need to worry about the base one valuse\strings.xml and ja/strings.xml the first in English, the second in Japanese.
The base string resources is inside values directory and the translation is inside values-xx or values-xx-xXX directory. For Japanese translation, the directory should be values-jp.
Why do I keep getting this "is translated but not found in default
local"
It means that you have one or more strings in values-xx but the strings didn't exist in your values directory.

Android localization for any region some country

I create folder values-ru (for any region). But with using Ukrainian language or Belarus i have an error.
android.content.res.Resources$NotFoundException: String resource ID #0x7f0d0037
Tell me, why i got an error. Does i must create values-ru-uk and etc. for all region?
You should define all your strings in the default (source) language, regardless of what translations you're adding.
These goes in: values/strings.xml.
If this is missing (or the string is missing in that file) then I expect that's why you get an error.
You can then add as many language files as you need: e.g:
values-uk/strings.xml. (Ukrainian)
values-be/strings.xml. (Belarusian)
or specific regions thereof: e.g:
values-ru-rUA/strings.xml. (Russian in Ukraine)
Disclaimer: I'm not an Android developer, but I've written localisation software that generates strings files.

Android Adding "values-en" folder causes "Couldn't resolve resource" warning

I have the next problem:
When I add a new folder called "values-en" and I move the strings.xml file from the default folder "values" to that "values-en", I always get the next error:
Couldn't resolve resource #string/my_string
I have cleaned the project and refresh and the warning is always there.
Is there any restriction where I must always have a strings.xml in the device folder "values"?
Someone has experimented the same?
Thanks in advance
You must have the values folder. To support multiple languages you can add the other values folders (values-en, values-fr, etc).
In the default values folder you declare your strings in your app's default language and in values-en the same strings but with their english translation.

Android : assets dir and multi language

Good morning. Into my android application I have in assets directory a file changelog. I have creato also the directory assets-it and I have put into the file changelog in italian language but when I start the application it always display the file into assets directory also if the device language is set to italian. Why ?
That is the expected behavior. Resources in res/ can be localized in that manner, but the assets/ directory cannot.
Since it's just a changelog, I'd recommend storing it as a localized string resource in res/values-LOCALE/. If you really want localization of assets, you could manually recreate it by getting the current locale and loading, e.g. assets/changelog-en, vs. assets/changelog-it, but I think that would generally not be a good idea, and it certainly isn't necessary in your case.
Try this:
put both changelog files into assets folder:
Path is for example: assets/en/changelog_file and assets/it/changelog_file
enter this into your values/strings.xml:
<string name="changelog_file">file:///android_asset/en/changelog_file</string>
put in your values-it/strings.xml:
<string name="changelog_file">file:///android_asset/it/changelog_file</string>
Like this you can call the string from the code:
getResources().getString(R.string.changelog_file) and it will call the values-en or values-it according to device locale.

Android: How to re-use strings in multi-language resources

This one puzzles me since my first android project. Consider multi-language string resources with 'en' as the default:
res/values/strings.xml <--- The default language 'en'
res/values-de/strings.xml <--- de
res/values-fr/strings.xml <--- fr
res/values-it/strings.xml <--- it
With that folder structure the Android Market entry for this app shows language support for "default, german, french and italian only". Yes, english is missing in that list.
Is it possible to "include" the complete default strings resource from the "values" folder in an additional "values-en" folder. And yes, I don't want to maintain that file in that new folder because everything is declared in the default string resource already.
Many thanks in advance.
Harald
I don't quite understand where the problem is. Just create a values-en directory and copy'n paste the XMLs from your default directory to the new one.
If you just want to have a kind of symbolic link to that default values directory so that when you change something inside the default directory the files i the linked directory represent the same changes then you just go to File -> New -> Folder select where the new folder should be created (in your case the res directory) and then hit on Advanced >> and there select Link to alternate location (Linked Folder) then browse to the directory you want to link to (in your case the values directory) and your done.
Now whenever you change something inside the values directory all your changes apply to the new linked directory.

Categories

Resources