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.
Related
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.
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.
I have two values directories - one for English and one default.
if the resource are located in any of those folders, i can use it.
But if there is no resource in default values directory and locale is other than English, it causes ResourceNotFoundException.
I understand why this happens and why Android was built this way (to prevent ambiguous resource usage in case there are more than one non-default resource files with this resource).
But is there any way to force Android use, for example, English resource bundle if resource couldn't be found?
The only option you have is to make sure the /res/values/strings.xml file contains every string in English but you must also have /res/values-no/strings.xml which has the Norwegian strings.
If /res/values-no/strings.xml doesn't have the resource it will drop back to /res/values/strings.xml. It's the only way to do it.
Is there a way to tag a strings resource folder with more than one language(values-en-es)?
My problem is that for Hebrew on some devices the language code "iw" and on others it is "he".
My current solution is to make two folders with the same content and only change their name
respectively.
I wonder if there is a more accurate way to do it?
Resource folder names can have multiple qualifiers but only one qualifier per type:
For example
values-en-rGB //Language + Region
is valid but
values-en-fr//Language + Language
is not valid, since it has multiple values for a single qualifier. So
values-iw-he
is not possible.
Source: Android Developers, Qualifier Name Rules.
However this doesn't mean you have to duplicate the files. Instead, you can create an Alias Resource.
Android Developers explains Alias Resouces like this:
Creating Alias Resources: When you have a resource that you'd like to use for more than one device configuration (but do not want to provide as a default resource), you do not need to put the same resource in more than one alternative resource directory. Instead, you can (in some cases) create an alternative resource that acts as an alias for a resource saved in your default resource directory.
For example, a String resource in one folder
<string name="app_name">My Awesome App</string>
can be referenced in another String resource in another folder as:
<string name="application_name">#string/app_name</string>
More about alias-resources on Android Developers.
You can make a File Link in eclipse, as described here.
So you have your values-iw/strings.xml with the real values and you make a File Link to that file in your values-he folder. This has the benefit that you do not have to edit 2 files, the linked 'file' gets updated automatically.
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.