Values-ja-rJP not found - android

I translated my application in the Japanese language. I added regularly the xml file, inside the folder values-ja-rJP .
Android studio is regularly set in UTF-8, but when I start my application on my device, the application uses the default language. I need to do something? the problem occurs only with the Japanese language. Thank you
<?xml version="1.0" encoding="UTF-8"?>
<resources>
<string name="action_settings">設定</string>
<string name="new_field">新規分野</string>
...
...
</resources>

Related

Android is ignoring /res/values-large/strings.xml

I want to use a different string resource on small screens but Android always uses the default string. Am I doing it wrong?
/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="continue">Continue</string>
</resources>
/res/values-large/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="continue">Continue to Next Page</string>
</resources>
#string/continue always resolves to "Continue", even on large screens. It does, however use the dimensions in /res/values-large/dimens.xml so I'm sure I'm using the right resource qualifier. I also tried /res/values-w550dp/strings.xml and it didn't work either.
Am I doing something wrong or is this a limitation of Android?
values-large is only available for dimens and styles, but not for string resources.
one could possibly add custom string-arrays and then look them up accordingly.
see Android Resource Types.

My app's language is not changing after changing the device language

I am translating my app to the Marathi language. I've made the value-mr-rIN/strings.xml for the Marathi language.
When I change my device language to Marathi the app still uses the default strings.xml which is English instead of using the values-mr-rIN/strings.xml.
What's the problem? I tried testing it on other devices still it shows English strings. I am pasting the code below
values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">App name</string>
<string name="test">this is a test</string>
</resources>
values-mr-rIN/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">अॅप नाव</string>
<string name="test">हे एक चाचणी आहे</string>
</resources>
A single line of code in gradle was causing this issue.
defaultConfig {
..
resConfigs "en"
}
The above line in gradle means use only English language resource. Which is used to save space by removing other language resources from the app.
I changed it to..
defaultConfig {
..
resConfigs "en" ,"mr"
}
Now it uses English or Marathi resources with respect to the device language.
May this helps you:-
just change your folder name
values-mr/strings.xml
To
values-mr-rIN/string.xml
After making this change it will work 100%.
See Demo Example:
Regular string.xml Output:-
Marathi string.xml Output:-

How to add localization setting in my app

Is there a way to add localization setting in my app? I'm going to add a preference/setting in my app and there is a localization option. So the user can change the language I have provided from the values string.
I was googling around but found nothing. Wondering you guys can help me, and give example or link to the tutorial.
You don't need to provide a setting for that, Android will do that for you. You just have to provide the translations for the languages you want to support.
You can do this for French for example by creating a folder named res/values-fr in your resources folder and putting your translations in there.
so in the res/values folder you would have a strings.xml file :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="q_map">Map</string>
</resources>
and in the res/values-fr you woud have another string.xml file :
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="q_map">Carte</string>
</resources>
Your app will use the translation that best matches the language that the user has selected on their device.

Android XML include another xml (non layout)

I have a settings.xml file that I use to set various global variables within my app. I want to be able to create sub xml files that I include in the settings.xml file because depending on the client, I change settings in this file so I want to make it easier on myself.
I know that there is a way to include layout files this way but I can't find any documentation that shows how to do this with plain XML on Android.
Any help would be much appreciated.
I think all you have to do is make an additional file which includes the settings you want.
Ie, I have strings.xml in values
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="main_title">Hello there</string>
</resources>
And I can create additionalstrings.xml in the values folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="additional">How are you?</string>
</resources>
I can refer to either R.string.main_title or R.string.additional, without having to say the file it came from.

change the language in android application

I'm writing an application were it requires to change the language of the application as and when the user requires. The data in different language is stored in the data base, from which the data is fetched and the UI is updated. I'm want to what should be done if device does not support the particular language font. Any help will be much appreciated.Thanks in advance. _/|_
I don't know more about this but ...
for example if you want your application to support both English
and French strings (in addition to the default strings),
you can simply create two additional
resource directories called /res/values-en (for the English strings.xml) and
/res/values-fr (for the French strings.xml).
Within the strings.xml files, the
resource names are the same.
For example, the /res/values-en/strings.xml file could
look like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello in English!</string>
</resources>
Whereas, the /res/values-fr/strings.xml file would look like this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Bonjour en Français!</string>
</resources>
A default layout file in the /res/layout directory that displays the string refers to the
string by the variable name #string/hello, without regard to which language or directory
the string resource is in.
The Android operating system determines which version of
the string (French, English, or default) to load at runtime.A layout with a TextView control
to display the string might look like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:text="#string/hello" >
</LinearLayout>
The string is accessed programmatically in the normal way:
String str = getString(R.string.hello);
It’s as easy as that.
More you will found Here

Categories

Resources