How can I start App with specified language in Android Studio? - android

I'm developing multi language android app.
I'd like to start app from Android Studio Run button with specified language.
Is it possible?
I'm expecting any option.(like Application Language in Xcode Run Options)
Why do I want this?
I'd like to check my app's layout and word, But Launching 'Settings app' is annoy. So I am looking for easy way to change device language setting OR Android Studio Run app options that can specify language each Running.
Thank you.

Generic file /values/strings.xml, will be used when locale does not match with one's present in your app. To create locales see these examples.
Please note that you have to create folders for each locale like value-de for German language, then create strings.xml file inside.
Generic strings.xml file:
app/src/main/res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name" translatable="false">Spin The Bottle</string>
<string name="text_hint">Tap on screen to spin the bottle</string>
</resources>
For Arabic language:
app/src/main/res/values-ar/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="text_hint">اضغط على الشاشة لتدور الزجاجة</string>
</resources>
For German language:
app/src/main/res/values-de/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="text_hint">Tippen Sie auf den Bildschirm, um die Flasche zu drehen</string>
Remarks
It is not necessary to translate each and every <string> inside strings.xml.
Notice I have placed translatable="false" on app_name as I wanted my app name to show the same for all locales.
Also app_name is not included in any other locale except generic values folder.

Related

Android does not display translated app name

Mainfest:
<application android:name="org.qtproject.qt.android.bindings.QtApplication"
android:label="#string/app_name"
...
<activity android:name="net.mynamespace.MainActivity"
android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density"
android:label="#string/app_name"
...
res directory contains Russian translation:
values/strings.xml
values-ru/strings.xml
values/strings.xml content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">English App Name</string>
</resources>
values-ru/strings.xml content:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Russian App Name</string>
</resources>
but devices with Russian language still display English app name.
What can be wrong?
Tried values-b+ru but it did not help.
If I copy values-ru/strings.xml to values/strings.xml the app name is displayed in Russian.
Did a quick Google search, but with no success:
How can I translate my Android app name?
Support different languages and cultures
Using resources for localization
What is the list of supported languages/locales on Android?
it helped me that I commented out this line in the android/build.gragle file:
defaultConfig {
//resConfig "en" //this one
minSdkVersion = qtMinSdkVersion
targetSdkVersion = qtTargetSdkVersion
{
And I also created two additional folders, in addition to the already existing android/res/values:
android/res/values-en
android/res/values-ru
In each of the three folders, I put a strings.xml file to make it look like this:
android/res/values/strings.xml
android/res/values-en/strings.xml
android/res/values-ru/strings.xml
Each file must contain the name of the application corresponding to the language described by two characters in the name of the folder in which it is located.

How do I submit my own translations for Android app buttons and strings?

I would like to provide my own translations for my new Android app without using the Translation Service in Google Play Console. I have already provided translations for the app descriptions but this would be for the buttons and strings in the app.
I started to upload the xml files into the Translation Service, but then decided I don't want to pay for something that I can already translate myself. What is the best way to do this?
For example, English:
<resources>
<string name="SaveSetting">Save setting</string>
<string name="ViewSettings">View settings</string>
<string name="SavedSettings">Saved settings</string>
<string name="settingHint">Enter the setting name</string>
</resources>
Portuguese:
<resources>
<string name="SaveSetting">Salvar configuração</string>
<string name="ViewSettings">Ver configurações</string>
<string name="SavedSettings">Configurações salvadas</string>
<string name="settingHint">Nome da configuração</string>
</resources>
You create multiple string files, one for each language and the phone will automatically use the one based on the OS settings
see here: https://developer.android.com/guide/topics/resources/localization
In your case you would put your default strings in the res/values/strings.xml and the Portuguese ones in a res/values-pt/strings.xml
If you are using Android Studio, you can Open the translations editor and then add the translations for your app's strings on any language.
For more details check: https://developer.android.com/studio/write/translations-editor
Try using this tree in your project with correct folders and strings.xml suffix:
MyProject/
res/
values/
strings.xml
values-b+es/
strings.xml
mipmap/
country_flag.png
mipmap-b+es+ES/
country_flag.p
"es" for Spain, "us" USA...
Take a look:
https://developer.android.com/training/basics/supporting-devices/languages

How to name an app with a different name for different languages (Unity3d, Android)

How can I name an app with a different name for different languages?
I am using Unity3d v. 5.2.3f1 Personal.
If it doesn't already exist, create a folder \Assets\Plugins\Android\res\values-xx for each additional language you want to support. Substitute "xx" with the two letter language ( not country! ) code.
Also make one without a language code ( \Assets\Plugins\Android\res\values ) which will be the default one, if your device doesn't match any of the languages you created.
In each of those folders, create an xml file called strings.xml containing this:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Hello World</string>
</resources>
Resource- http://www.bitsofbas.com/blog/post/32/localizing-app-name-in-android
Update:
The folder name for localized strings should be like this scheme:
<resource type>-b+<language code>[+<country Code>]
e.g. values-b+es/ … for spanish language
Docs: Support different languages and cultures

Hindi Text in Eclipse on Android

How can one directly input Hindi text into the eclipse IDE on android?
I would like to type Hindi text directly into the eclipse IDE without copy/pasting it from somewhere else, see this demo for an example of writing Hindi text quickly.
I would like to do the same thing in the eclipse IDE.
Use hindi texts inside String.xml file like
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hindiText"> पवन कुमार</string>
</resources>
And use this on your app's TextView
<TextView
android:id="#+id/textView"
android:gravity="center_horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hindiText"
android:textSize="28sp" />
Yes Hindi language can support in Android devices. You need to follow the steps.
Step 1:
Just create one values folder under resources like values-hi and add strings.xml file inside of this folder. You can add your translated strings in this strings.xml file.
example
<string name="your_text">अपका संदेशर</string>
Step 2:
If you call your strings from the other layout xml files then just call like the following
android:ext="#string/your_string"
Step 3:
You can also use string values in java code programmatically.
I think you are looking forward for multi-language(English AND Hindi) support for your application. If so,
strings.xml in values folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="welcome">accueil</string>
<string name="email">adresse e-mail</string>
<string name="password">mot de passe</string>
<string name="login">connexion</string>
<string name="signup">Ne pas avoir un compte? signer</string>
</resources>
strings.xml in values-hi folder
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="welcome">स्वागतम</string>
<string name="email">ईमेल पता</string>
<string name="password">पासवर्ड</string>
<string name="login">लॉगिन</string>
<string name="signup">खाता नहीं है? साइन अप करें</string>
</resources>
for more references please check this link
EDIT (as per the comment)
Try this
1.Windows > Preferences > General > Content Types, set UTF-8 as the default encoding for all content types.
2.Windows > Preferences > General > Workspace, set "Text file encoding" to "Other : UTF-8".
For more references, please check this
blog
Use UTF-8 encoding in android studio , below is setting page , using
utf-8 encoding will allow you to paste hindi fonts in xml and java
code.
For Eclipse IDE : below is path to configure the encoding :
Preferences > General > Workspace > Text file encoding
Today i found solution of my question.
i found that Google develop many inputtools for windows OS , Android
and for Web in many language that use for fastly type any language with the help of English typing.
So i download inputtools at URL : Download Page thank you Everyone for help me

Compare Android String xml files

I have two string xml for two different languages, I would like to know the different between those xml files.
For example, there is one xml for English,
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Keep Accounts</string>
<string name="insertNewOne">Insert Accounts</string>
<string name="browseRecord">Browse Records</string>
<string name="set">Setting</string>
</resources>
And another xml for other language,
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Example</string>
<string name="insertNewOne">Example</string>
<string name="browseRecord">Example</string>
<string name="dateNoColon">Example</string>
</resources>
We can see the difference is xml for English has element string name="set", and the other has not. On the other hand, the xml file for other language has element string name="dateNoColon" but the xml for English has not.
In this case, I would like to know the English xml lacks the element string name="dateNoColon", and other xml lacks the element string name="set".
Android Studio has translations editor starting of 0.8.12 version. You can find there missing translation strings.
You can enable check for missing translations in Lint tool. There are "Missing translation" and "Extra translation" checks.
Extra translation If a string appears in a specific language translation file, but there is no corresponding string in the default locale, then this string is probably unused. (It's technically possible that your application is only intended to run in a specific locale, but it's still a good idea to provide a fallback.).
Incomplete translation If an application has more than one locale, then all the strings declared in one language should also be translated in all other languages.
Suppose if the device is set to Other language, Android will look for title in the otherlanguage.xml file in value folder. But if no such string is included in that file, Android will fall back to the default, and will load title in English from the english.xml file.
For more detail go to http://developer.android.com/guide/topics/resources/localization.html#using-framework
I wrote a small tool for that: resdiff.
Check it out! https://github.com/danijoo/resdiff
Try sorting both files using some perl or bash script or something like that for example, using bash:
sort temp.txt -o temp.txt
and then look at the diff for example using DiffMergeit.
Use Android Lint to find both incomplete translations i.e. strings missing in a language variant and extra translations i.e. strings introduced in a language variant but missing in the default locale.
In Android Studio you can run Lint (and some other analysis tools) with Analyze -> Inspect Code.

Categories

Resources