As I asked in the following question:
Arabic number in Arabic text in Android
if I use the arabic locale ar-ae or ar-sa the numbers are shown using Hindu-Arabic numbers.
I need to show the digits like in English: "1234567890".
I used to use the trick of setting the numeral extension
Locale.Builder builder = new Locale.Builder();
builder.setLocale(savedLocale).setExtension(Locale.UNICODE_LOCALE_EXTENSION, "nu-latn");
Locale locale = builder.build();
The problem is that after you do that the resource lookup gets broken and with Nougat it just does not work anymore.
Is there a way to see the "normal" digits even using the Arabic locale for ae and sa?
One workaround is to replace the font for the digit characters. You'll be able to keep your original font for the text.
I would recommend to do that in a clean way by extending TypeFaceSpan.
Take a look at this question.
If you need some code, let me know and I'll update this answer.
You should trust the locale you are using. If you are specifically targetting ar_SA then you should let it render things the way it's meant to for that country. If you just want Arabic language but want the western Arabic numbers then try a locale from one of the western Arab countries, ar_MA for example.
For now what I did is to use a custom font and to replace in the file for the custom font the digits with the Hindu-Arabic numbers with the correspondent char for the "western-Arabic" number.
Please check
how to remove characters from a font file?
EDIT
It is now possible to use a locale like for example:
<item>ar-AE-u-nu-latn</item> <!-- Arabic (United Arab Emirates, Western Digits) -->
This is taken from here
Related
I'm trying to learn Android Studio (v. 3.6.3). I am setting the attribute textAllCaps to true in the XML code source forTextView, as follows:
"android:text="#string/quantity"
"android:textAllCaps="true"
However, on the screen, the word "Quantity" is capitalized incorrectly as "QUANTİTY" (the uppercase i is dotted).
The letter "İ" (dotted uppercase i, Unicode U+0130), is used in Turkish, not in English. The language for the app is English.
I could not figure this out. Do you know any solution for this?
I have the following TextView within a ConstraintLayout:
<TextView
android:id="#+id/title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="3"
android:textAppearance="#style/TextAppearance.AppCompat.Title"
... />
When the text is too long to fit in one line, it will break into two lines. However, if the system language is set to Swedish it will break in the middle of words without adding a hyphen, like so:
Some text that is br
oken into two lines
I'm not sure if this is an accurate example, but you get the idea.
What I want is this:
Some text that is br-
oken into two lines
It does work when the system language is set to English. But it should also work for Swedish.
I have tried all possible combinations of android:breakStrategy="..." and android:hyphenationFrequency="..." on the TextView.
compileSdkVersion 28
targetSdkVersion 28
minSdkVersion 28
I think that the problem comes from localization and characters encoding in different languages.
I suppose you are using the translation editor to support localization. Try getting the string of each textView (etc...) and converting it to utf-8 format using this:
URLEncoder.encode(your string, "utf-8");
Then set the textView text to this string:
textView.setText(your string);
Hyphens are only added to connect words in line breaks if the language is set to English. This is probably a bug. Source: https://issuetracker.google.com/issues/37087785 https://issuetracker.google.com/issues/37010641 https://issuetracker.google.com/issues/79936443
Not every languages is available for hyphenation in every Android version. E.g. Swedish and Polish are not available in Android API 33; they should be with the following Android release.
To perform proper hyphenation Android needs the language "dictionary" which are stored here: https://cs.android.com/android/platform/superproject/+/master:external/hyphenation-patterns/;l=1?q=hyphenation-&sq=
When it doesn't have the language dictionary available, it tries to break as best as it can, based on the available space.
I have app in android studio and When i install APK and Language is English,
it show language of app like i want, but when phone language is different like Persian, it show other language in app and i don't want it...
how i can force app to use same English even language of phone changed?
my application is in Android studio and just one line have problem, mean there is a line words in application, and when i change language phone, it change to a different language same i don't want.
this is my main.xml (same line code
<TextView
android:id="#+id/diffText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Dhuhar After one hour 10 min"
android:textColor="#ffffff"
android:textSize="16dip"
android:textStyle="bold"></TextView>
</LinearLayout>
And this one is not available in my string.xml, it mean it not translated, correct?
and cause "one hour 10min" is not stable, there is easy way i force it to use for all language same use for english?
I set below code in oncreate and solved
Locale.setDefault(Locale.ENGLISH);
If you want only english for all languages, dont set different language xml.. Just provide only default strings.xml.. app will show what ever text in strings.xml.
If you don't define your string in other language files (only write <string name="yourstring" translatable="false">Your english string</string>) then you will get your expected behavior.
That is because it takes the strings from values/ if they are not available in the specific folder for the current language (e.g. values-de/)
i am currently working on one Android Application and i have to set layout according to country like if application is for Korea layout color must be blue and for india layout color must be red.
So how can i achieve that?
i know about multiple language
values-kr // for Korea
values //for English
values-fr // for french
but for layout i don't know.
Help Me.
Thanks in Advance
You can create a Style for each Values or in java code programming you can use a simple if statement that detects your location inside "oncreate method" and setbackground layout according to what you want using a drawable.
You have to determine your system language. You can use
Locale.getDefault().getLanguage();
to get the usual language code (e.g. "de", "en").
Then, create a base Activity for your app and override onCreate to set the theme according to your system language. Derive all your other activities from this base Activity. Check this tutorial.
follow type of languages
res/values/strings.xml
Contains English text for all the strings that the application uses,
including text for a string named title.
res/values-fr/strings.xml
Contain French text for all the strings, including title.
res/values-ja/strings.xml
Contain Japanese text for all the strings except title.
How to display Korean Words in android app
You may use this piece of code:
TelephonyManager tm = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
String locale = tm.getSimCountryIso();
and choose:
if (locale.equals(pk))
{
view = inflater.inflate(R.layout.hazel_quick_form, container, false);
} //fragment
Take example of TextView.
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world"
android:textColor="#color/textcolor" />
you can have colors.xml file in different locale folders like values , values-fr etc.
In example textview #color/textcolor can be defined with those saperated colors.xml files with different colors for different locales.
look at this.
Android will do the next magic automatically based on locale.
I have two unfocused TextView in the single layout. I want to show Arabic text on one TextView and English text on another TextView. I have use values/strings.xml for English and values-ar/strings.xml for Arabic text. My problem is Arabic text not showing in the TextView. If I change the custom locale to ar means its showing. How to show the Arabic text without changing the custom locale?
Put both arabic and english text in each strings.xml
Its default behaviour for Android. It will take locale information from system and map appropriate string resource from values-ar.
Text you want to show in Arabic you have to take entry in values/strings.xml and have to put those arabic character that you want to display.
please share the result when you tried this.
To do this we need the font file for Arabic fonts. For example ,we have the Arabic font file name as arabicfont.ttf. Save this file into the assets folder then use the bellow code
arabicTextview.setTypeface(Typeface.createFromAsset(getContext().getAssets(),"arabicfont.ttf"));
arabicTextView.setText("ur text");
Like wise we can set any type of text with out using the Locale