What is the solution for character cannot mapped error..? - android

An error message is appeared when i was trying to create an app in malayalam.What can i do to solve this.
Error:Some characters cannot mappped using "Cp 1252"character encoding.

Switch your text encoding to UTF-8.
In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.
do as follows:
download AnjaliOldLipi.ttf font.that's the malayalam font .search google for the file.
under your android assets folder create if not exist the folder fonts: assets/fonts/AnjaliOldLipi.ttf
then display texts this way were textview is a TextView: textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf"))

Related

XElement write numeric character reference

I'm trying to write a strings.xml file for our android app via a resource provider from our translation tool.
So the procedure is like this:
-Start translation tool and import strings.xml
-Do the translations
-Use the custom resource provider to export strings.xml
-Import strings.xml to android project
The strings.xml file has the following structure:
Send data. Please wait…
As you can see, the char … (Ellipsis) is written as &#8230 (NCR).
Android needs it to be like this.
Now to my problem, the translation tool saves the Ellipsis as char … and not as &#8230. I then customized the resource adapter to Replace("…","&#8230")
But now my XML File looks like this:
Send data. Please wait…
So it's replacing the char & with &
Is there a possibility to make an XElement with &#8230 as value?

File Print Wizard in Android Studio

I want to print the source code, Opened File-> Print.
In the print its printing the full file path on top. I want to print only the file name. How can I do this?
The Text line $FILE$ is printing the file path on top of the paper. I tried $NAME$,$FILENAME$, etc,. but not working? Any hope?
You can print the file name with $FILENAME$, Check IntelliJ IDEA documentation here.
Text line :- In this text box, specify the contents of the header or footer. If necessary, combine plain text with print keywords. By default, IntelliJ IDEA suggests to print the name of a file $FILE$ in the header and the current page number $PAGE$ of all pages $TOTALPAGES$ in the footer.
The following print keywords are recognized:
$FILE$ prints fully qualified file name.
$PAGE$
$DATE$
$TIME$
$FILENAME$ prints file name without path.
$TOTALPAGES$

How to import/export Android string resource to Excel for localization?

I use Android Studio in app development. I want to translate strings by exporting/importing the Android language resources (strings.xml) to Excel file (xlsx). What is the best way to do it?
If anyone else needed the answer,
from res -> strings -> right click-> Open Translations Editor. Select data/variable you need then copy and paste data from Translations Editor to excel . done.
Since CTRL+A not working now in the android studio.
There is one way to convert the android strings file to CSV and then translate it with the help of google translator and then again convert back to XML.
https://www.skydevelopers.net/blog/2-best-ways-to-translate-the-android-strings-file/
here is a blog in detail
Export Strings resource file to csv
Get its content translated(probably from google translate)
convert back the Translated file to Strings.xml(android string resource file)
I used http://convertcsv.com/csv-to-xml.htm this website for converting csv file to strings resource file
need to mention Custom output template to convert it to strings resource file
<string name="{f1}">{f2}</string>
put this in template section provided
website also displays the desired converted output file
As many others pointed out, pressing Ctrl+A in the Translations Editor doesn't work since Android Studio 3.2
I work for a company that outsources translations constantly, so we need to convert android strings to and from xls files.
The only solution that worked for us reliably is this fork of the older android-lang-tool. Just build with maven and run the jar.
It exports strings, string-arrays, plurals and their key-values to an xls file. It even exports the comments.
I would suggest the best tool for android app string localization is the Translations Editor that is inbuilt into Android Studio.
The reason this is a great approach is you are able to make the process both easier for translators and less prone to errors. The XML string files in Android Studio support XLIFF notations that are a standardized method to aid string localization.
By utilizing XLIFF notation in your XML string files you can do the following to help the translators:
Provide additional context for declared strings
Mark message parts that should not be translated
To use XLIFF in your Android string XML files you need to include the XLIFF 1.2 namespace:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
Here are a few examples of strings from the android localization documentation:
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Example placeholder for a special unicode symbol -->
<string name="star_rating">Check out our 5
<xliff:g id="star">\u2605</xliff:g>
</string>
<!-- Example placeholder for a for a URL -->
<string name="app_homeurl">
Visit us at <xliff:g id="application_homepage">http://my/app/home.html</xliff:g>
</string>
<!-- Example placeholder for a name -->
<string name="prod_name">
Learn more at <xliff:g id="prod_gamegroup">Game Group</xliff:g>
</string>
<!-- Example placeholder for a literal -->
<string name="promo_message">
Please use the "<xliff:g id="promotion_code">ABCDEFG</xliff:g>” to get a discount.
</string>
</resources>
To access the Translations Editor in Android Studio, select Open Translations Editor from the context menu for your XML string file (ie. strings.xml) in your project tree (see below).
Convert your strings.xml to csv xml-to-csv
Import to Google Sheets
Translate using the formula =GOOGLETRANSLATE(B2, "auto", "de")
Generate output in another column using =CONCATENATE("<string name=",char(34),A2,char(34),">",C2,"</string>") where A2 is the resource_ID and C2 is the translated string
Copy the whole output column and paste inside the <resource>...</resource> tag
As Saad Mahmud answered, you can copy from the translation editor (ctrl+a ctrl+c) and then paste into a spreadsheet.
You can copy it back from a spreadsheet to the translation editor by only copying the "default value" and other languages columns, click on the topmost default value and paste (ctrl+v).
It also works with subsets (both subsets of rows and columns), as long as they are next to each other.
Be aware that empty cells in the spreadsheet will not blank out the translation in the editor, it will leave the current untouched.
Also be careful that you haven't added or removed any translation keys since the spreadsheet was created...
Export or copy to excel only supported in Windows PC.
Still not yet in MAC
As many others pointed out, you can't simply copy and paste translations from and into Translations Editor since Android Studio 3.2.
The simplest solution I found was saving the Excel file with translations as CSV file and then converting it to XML with regex and vice versa.
To "import" translations the steps:
Save xls/xlsx file with key in first column and translation in second column as CSV file (If you have file with non-ANSI caracters use Google sheets, because Excel doesn't support saving in CSV using utf-8)
Open csv file in text editor which supports "find and replace" with regex (eg. Notepad++)
Open "find and replace" and set regex search
Search ^([^,]*),(.*)$ and replace it with <string name="$1">$2</string>
Copy file to string resources file between tag
Fix possible mistakes
You can use similar method in reverse for "export". Use <string.+name="(.*)".*>(.*)</string> for finding and $1,$2 for replacing. But it only works if every string tag in in one line.
NOTE: If your res folder doesn't contians strings.xml then Android Studio won't show "Open Editor" in top right corner of the strings.xml file(Open the file). In my case all my string res files are named like strings_feature.xml
To copy/paste from Translations Editor use Android Studio 3.2 Version and below. It allows copy/paste of full column.

Issue with config file while using Arabic text in android?

I am using ant tool for customizing variables. For that i have used
property file and i am giving my variable's values in this file. when i
am giving any value is English in property file and building by ant
command then i am getting
auto generated config.java file that have the value of property file but
if i have given value in Arabic language and building by ant command
then Config.java file does holds some garbage value:
For Example:
in property file i am putting values like this:
config.language_label = رقم الموبايل
after building getting value like that:
public final static String LANGUAGE_LABEL = "رقم الموبايل";
Thanking In Advance.
Please note:
-Android 2.1 does not have Arabic font.
-Android 2.2 has Arabic font but does not show your word correctly.
-Android 3.x supports Arabic completely.
So first of all make sure which version you are using.If you are using 3.x
How To Implement RTL and Arabic in Android App:
Please see page number 25 having following heading: Advanced: right to left support
http://commondatastorage.googleapis.com/io-2013/presentations/147%20-%20Android%20Apps%20for%20a%20Global%20Audience.pdf
Java Properties files have to be encoded in ISO 8859-1.
The Properties file in your question appears to encoded in UTF-8. You can use the JDK's native2ascii tool to convert the text from UTF-8 to ISO 8859-1.
Running native2ascii on the given Properties file results in the following:
config.language_label = \u00d8\u00b1\u00d9\u201a\u00d9\u2026 \u00d8\u00a7\u00d9\u201e\u00d9\u2026\u00d9\u02c6\u00d8\u00a8\u00d8\u00a7\u00d9\u0160\u00d9\u201e

How to show Hindi text in android?

I am trying to paste Hindi characters in an array with elements like
String[] arr = {"आपका स्वागत है","आपका स्वागत है"};
but its giving error i.e.
"some characters cannot be mapped using "Cp1252" character encoding"
while saving this.
Switch your text encoding to UTF-8.
In Eclipse go to Window -> Preferences, select General -> Workspace. From the Text file encoding dropdown, select UTF-8.
Thanks i found the solution...
create an array under the value folder
Use the font that support Hindi under the assets folder
textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf")); its working fine...
You need UTF-8 encoding, not Cp1252, and Unicode.
Thanks i found the solution...
Create an array under the value folder
Use the font that support Hindi under the assets folder
textview.setTypeface(Typeface.createFromAsset(getAssets(),"fonts/Hindi.ttf"));
its working fine...

Categories

Resources