java - android reshape all resource file string -


I'm working on a Android app and want to translate it into Persian language. All string values ​​in the project are saved in a resource XML file in some string values ​​in the layout files and in some sections (R. string) is done. When using Persian text in Android , it needs to be resized to display correctly.

I want to redesign all the resource string values ​​without calling the reciep method for every string value

Can anyone tell me how to do this?

Some ideas: string class override
override resource class

Android provides functionality for a multilingual app already. It's better to use the framework function to change your text and instead of different versions of your app for each language. In that case, the App Tools chooses a suitable language from the available languages ​​based on locale settings.

So basically you will start by creating the necessary directory structure (link above):

  MyProject / res / values ​​/ strings.xml value- fa / strings Xml   

and then you fill in the string value in the file, example:

English (default locale), /values/strings.xml

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Resources & gt; & Lt; String name = "title" & gt; My application & lt; / String & gt; & Lt; String name = "Hello_World" & gt; Hello World! & Lt; / String & gt; & Lt; / Resources & gt;   

Persian, /values-fa/strings.xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Resources & gt; & Lt; String name = "title" & gt; ... & lt; / String & gt; & Lt; String name = "Hello_World" & gt; ... & lt; / String & gt; & Lt; / Resources & gt;   

(cited and optimized from the link above)

Solution for Language
New Fashion Use for Fiber To do this, the settings string is not possible in the string value, therefore the XML layout (AFAIK), so the following offers assume that all string values ​​are programmatic Set as

Using Global Static Casing Function #

  public static final string getLocalizedString (int resId) {if (Locale.getDefault () .tasting (.). PAR ("FAIR") (Persian Rishp Recharge. Resize (getResources (.getString (resId)); } And {return getResources (). GetString (resId); }   

You can now use this function to load string (you must change each event) or you override the GetRessource method Personally I prefer to use a static function due to other problems related to other types of loading resources compared to string , side effects etc.

Creating a custom class # 2 with overriding settest () for each used UI widgets. Another possibility is to create custom UI widgets which PersianReshape call on reshape () . Such as EditText :

  custom text field edits text for the class {@ Override Public Wide Set Text (string text) {super .set text (Persian respepe.rap) (Text)); }} [...] Custom TextFilts myTextBox = New Custom TextField (); myTextBox.setText ("....");    

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -