Convert Android application from one language to another - android

I need to convert my android app from English Language into Arabic Language,
but the database inside the APK is encrypted.
Anyone know what to do?

You should add new string in value with new name ex:
Strings-en.xml
Strings-ar.xml
and translate all value in your string file

Related

How to change Locale without re-launching application?

Basically what I am trying to do is,
I start with MainActivity(activity_main) go to SettingActivity(activity_setting) & change my locale from given options(like french, english, dutch etc.)
So what I have done till now is...
OnClick of language name it re-create SettingActivity(activity-setting) & change it's string values according to language selected.
What I really want is Without re-creating Activity, All string values should be applied according to that selected language.
All suggestions & Answers are greatly appreciated.
Thank you in Advance.
Simply change the language property first.
Then call a new function that sets all strings displayed in the UI to the right language.
Pseudocode:
TextView myTextView = (TextView) findViewbyId(R.id.tv1);
myTextView.setText(yourCustomGetLocaleFunction("some id of the string you want to display", "some language name"));
But that's a bad approach. You should let Android handle the language of your app. Just localize the strings.xml file (you can load strings from the file from code).
Edit:
To change the language of your app for the moment, you can use the Code from this solution:
How to change android app language without changing phone language?

localizing application non default strings?

Hi I am trying to localize my android application and I read up on how by reading this tutorial http://developer.android.com/guide/topics/resources/localization.html but after looking through it, I couldn't figure out how to change the language. I have the default values in res/values/strings.xml and I have my other strings in res/values-latin/strings.xml. but I cant figure out how to make my application use the strings in res/values-latin/strings.xml instead of the default. Could someone explain this to me?
How about if someone clicks a change language button how could I inform the application to change all the strings?
Thank you!
Android will do it for you automatically.
When a user runs your application:
The Android system selects which resources to load, based on the
device's locale.
Example:
Suppose that your application's default language is English. Suppose also that you want to localize all the text in your application to French. In this case, you could create two alternative strings.xml files, each stored in a locale-specific resource directory:
res/values/strings.xml
Contains English text for all the strings that the application uses.
res/values-fr/strings.xml
Contain French text for all the strings.
If your Java code refers to R.string.title, here is what will happen at runtime:
If the device is set to any language other than French, Android will load English title from the res/values/strings.xml file.
If the device is set to French, Android will load French title from the res/values-fr/strings.xml file.
With latin it will not work. You should search alternative method.
My solution in java:
public final class English {
String moon = "Moon";
String earth = "Earth";
String mars = "Mars";
}
public final class Latin {
String moon = "Luna";
String earth = "Terrae";
String mars = "Mars in Latin";
}
Then in your code you can aceess them:
TextView textView = (TextView) findViewById(R.id.my_text);
textView.setText( Latin.moon );

Store language independent strings in Android resources

How would I store some language independent values like website address in an Android project. I am currently storing it inside my strings.xml. This does not look good as if I add another language and translations, this entry will still have the same value and will be duplicated.
I would also like to get some tips on creating Android projects with I18N in mind.
You don't need to create the same keys in the translated xml file again. If Android does not find link in the German/Spanish/Whatever language file, it will fall back to the original key stored in the default string.xml.
I suggest to implement the English version first and after that let someone translate it.
for i18n-format, you can create some resources folder for one local :
/res/values <- default locale
/res/values-fr <- values for french locale
...
For more examples, read documentation : http://developer.android.com/guide/topics/resources/localization.html
For language independent Strings just create a class with constants :
public class MyIndependentStrings {
public static final String SOME_STRING = "Value";
}
Usage :
tvMyTextView.setText(MyIndependentStrings.SOME_STRING);
In this case you will use constants and not i18n Strings from ../values/strings.xml
Try putting language independent strings in:
\res\values-nodpi\strings.xml

Android - lookup an xml element node name from its value

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?
Use string array http://developer.android.com/guide/topics/resources/string-resource.html#StringArray
String[] files = getResources().getStringArray(R.array.file_names);
In code you can loop through all values to find which one you need.

Which strings to store in strings.xml?

Are there any suggestions on which strings you should store in strings.xml and which strings can be stored as String objects? For example, do I have to put a string into strings.xml, if I use it only to complete a certain action and then it can be destroyed? And what is the main reason in storing strings in xml? Thanks in advance for your answers.
Any string that will be displayed to the user should be in strings.xml. This is useful in case you ever want to support other languages for your application. If you do, you just create a new strings.xml file that language with translated values. You can learn more about it here.
One reason is multi-language support.
You should store the strings that you use in Activities - TextView, button's caption and so on.
You should put most constants in strings.xml, your app title, button names, textview contents...mostly things that wont change in your application.
Another reason for storing strings in xml is for localization. You can store different files for each different Locale or language, and Android will grab the correct file for the phone's selected Locale or language.
Here is a link to the String resource Android page, it will go more deeply into how the language support is done.
You don't store all the strings in strings.xml, but only strings constants related to user interface, the strings that you want to translate in different languages.
You can have different folder like :
values
values-fr
values-de
in each a strings.xml file with you UI messages translated in many languages.
Regards,
Stéphane

Categories

Resources