݇†ó£Œ´ ÜŠO
«èê¡èœ ðô ®¬õv
èœ ñŸÁ‹ ðô ªñ£N
èO™ ðò¡ð´A¡øù. à¼
õ£‚èŠð´‹ ÜŠO«èê¡èœ
ªê™«ðC ðò¡ð´ˆ¶‹
ªñ£N‚° ãŸð îèõ™èœ,
â‡èœ, Ý...
ÜŠO«èê¡ à¼
õ£‚°‹ «ð£¶, ªñ£N
‚° ãŸð îèõ™èœ,
ðìƒèœñŸÁ‹ç¬ð™
è¬÷ «î˜‰ªî´‚è
«õ‡´‹.
ÜŠO«èê¡ ªêò™
ð´‹«ð£¶,«î˜‰ªî´‚
èŠð†´œ÷ªñ£N‚°
...
ðì‹-7
ðì‹-9
ðì‹-10
ðì‹-12
«ð£°‹ ÜŠO«èê¡ ªè£´ˆ¶ ªî£ìƒè
«õ‡´‹.
W›è‡ì îèõ™è¬÷ ªè£´ˆ¶ ªî£ìƒè
«õ‡´‹.
Project Name:Hello 10N
App...
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Hallo,
Lokalisierung</string>
<string name="tex...
Upcoming SlideShare
Loading in...5
×

Using many languages in single Android App (in tamil)

197

Published on

Dr. Ramkumar Lakshminarayanan article published in Tamil Computer Magazine. The content is about Using many languages in single Android App.

Published in: Mobile
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
197
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
25
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Using many languages in single Android App (in tamil)

  1. 1. ݇†ó£Œ´ ÜŠO «èê¡èœ ðô ®¬õv èœ ñŸÁ‹ ðô ªñ£N èO™ ðò¡ð´A¡øù. ༠õ£‚èŠð´‹ ÜŠO«èê¡èœ ªê™«ðC ðò¡ð´ˆ¶‹ ªñ£N‚° ãŸð îèõ™èœ, â‡èœ, Ý®«ò£ ç¬ð™èœ, ðí °Pf´èœ ñŸÁ‹ ð ì ƒ è¬÷ ñ£ŸP ܬñ‚è (Locales) ðò¡ð´Aø¶. ꣡ø£è â¡Â¬ìò ªê™«ðCJ¡ îèõ™ ªîK »‹ ªñ£NJ¬ù ¬õˆ ¶œ«÷¡. Üîù£™ ðì‹ -1™ îèõ™ ݃Aôˆ F½‹ ñŸÁ‹ HK†®w ªè£® F¬óJ™ «î£¡P »œ÷¶. Ü´ˆîî£è ðì‹-2 setting->Language Key board-™ ªñ£NJ¬ù ñ£ŸP ܬñ‚è º® »‹. (ðì‹-3) Þƒ° ªñ£NJ¬ù Germen ݇†ó£Œ®™ ðô ªñ£Nèœ ðò¡ð´ˆ¶‹ º¬ø! <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com /apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/text_a" /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:gravity="center_horizontal" android:text="@string/text_b" /> <Button android:id="@+id/flag_button" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="center" /> </LinearLayout> <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Hello, L10N</string> <string name="text_a">Shall I compare thee to a summer"'"s day?</string> <string name="text_b">Thou art more lovely and more temperate.</string> <string name="dialog_title">No Localisation</string> <string name="dialog_text">This dialog box"'"s strings are not localised. For every locale, the text here will come from values/strings.xml.</string> </resources> Deutsch (Deutschland) ñ£ŸP ܬñ‚A«ø¡. e‡´‹ ÜŠO«èê¬ù ª ê ò ™ð ´ ˆ¶ ‹«ð £ ¶ ðì‹ 4-™ àœ÷¶ «ð£¡ø ªü˜ñ¡ ªñ£N ñŸÁ‹ F¬ó «î£¡Á‹. Þ¬î «ð£¡Á Langu age& Keyboard â¡ø «î˜ M¬ù English(Unite Sta tes) â¡Á ñ£ŸP ܬñˆ  ðì‹ 5-™ àœ÷¶ «ð£¡Á F¬ó «î£¡Á‹. Language&Keyboard â¡ø «î˜M¬ùFrancais(France) â¡Á ñ£ŸPù£™ ðì‹ 6-™ àœ÷¶ «ð£¡Á F¬ó «î£¡Á‹.  ༠õ£‚°‹ÜŠO«èꡫ ªî´‚èŠð´‹ ªñ£N‚° ãŸð ñ£Áî™ ãŸð´ñ£Á ܬñˆFì º®»‹. ðì‹-1 ðì‹-2 ðì‹-3 ðì‹-4Gó™-1 Gó™-2
  2. 2. ÜŠO«èê¡ à¼ õ£‚°‹ «ð£¶, ªñ£N ‚° ãŸð îèõ™èœ, ðìƒèœñŸÁ‹ç¬ð™ è¬÷ «î˜‰ªî´‚è «õ‡´‹. ÜŠO«èê¡ ªêò™ ð´‹«ð£¶,«î˜‰ªî´‚ èŠð†´œ÷ªñ£N‚° ãŸð îèõ™èœ, ðìƒ èœ ñŸÁ‹ ç¬ð™ è¬÷ 裇H‚è «õ‡ ´‹. Localization ꣘‰î ÜŠO«èê¡ à¼õ£‚°‹ «ð£¶ F†ìI´î™ º‚Aòñ£ù ªêòô£°‹. ݇†ó£Œ´ Í¡Á Mîñ£ù K«ê£˜v ç¬ð™è¬÷ ðò¡ð´ˆ¶A¡ø¶. ܬõ, res/drawable, res/layout ñŸÁ‹ res/ value à¼õ£‚èŠ «ð£°‹ ÜŠO«èê¡ Þó‡´ ªì‚v† MÎ ñŸÁ‹ ð†ì¡ ªè£‡®¼‚ °‹ ð†ì¬ù AO‚ ªêŒî¾ì¡ îèõ™ F¬óJ™ «î£¡Á ñ£Á à¼õ£‚èŠ «ð£A«ø£‹. ¯ç𣙆 ªñ£N ò£è British, English ñŸÁ‹ Default Loca tion (Þì‹) United Kingdom â¡Á «î˜‰ ªî´ˆ¶ ªè£œÀƒ èœ. à¼õ£‚èŠ Ý¡†ó£Œ´ -2 Þ󣋰ñ£˜ ªô†²Iï£ó£òí¡ 11 package com.ram.helloln; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.os.Bundle; import android.view.View; import android.widget.*; public class HelloLNActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Button b; (b = (Button)findViewById(R.id.flag_button)).setBa ckgroundDrawable(this.getResources().getDra wable(R.drawable.flag)); // build dialog box to display when user clicks the flag AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setMessage(R.string.dialog_text) .setCancelable(false) .setTitle(R.string.dialog_title) .setPositiveButton("Done", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.dismiss(); } }); final AlertDialog alert = builder.create(); // set click listener on the flag to show the dialog box b.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { alert.show(); } }); } } ðì‹-5 ðì‹-6 ðì‹-8 Gó™-3
  3. 3. ðì‹-7 ðì‹-9 ðì‹-10 ðì‹-12 «ð£°‹ ÜŠO«èê¡ ªè£´ˆ¶ ªî£ìƒè «õ‡´‹. W›è‡ì îèõ™è¬÷ ªè£´ˆ¶ ªî£ìƒè «õ‡´‹. Project Name:Hello 10N Application Name: Hello, LION Package Name: com.ram.hello10n Create Activity:HelloLION Min SDK Version:3 res/layout/main/.xml-L™ ªì‚v† MÎ ñŸÁ‹ ð†ì¡ à¼õ£‚è Gó™ 1-™ àœ÷ Gó™è¬÷ ðò¡ð´ˆî «õ‡´‹. Ü´ˆîî£è ÜŠO«èê‚° «î¬õò£ù String.xml ç¬ðL¬ù à¼õ£‚è «õ‡´‹. Þƒ° "text-a", "text-b", "dialog-title", "dialog- text" «ð£¡ø¬õ‚è£ù îèõ™ â¡ù «î£¡ø «õ‡´‹ â¡ðîŸè£ù îèõ™ ªè£´‚A«ø£‹. ÞîŸè£ù Gó™ -2™ àœ÷¶. ªñ£N‚° ãŸð ªè£® ñ£ø «õ‡´‹. Üîù£™ Default Ýè drawable-hdpi â¡ø ç«ð£™ìK™ developer.android.com/ images/ hello-l10n/flag.png Ü™ô¶ «õÁ Þ¬íò î÷ˆFL¼‰«î HK†®w ªè£®J¬ù flag. png â¡ø ªðòK™ «î˜‰ªî´ƒèœ. main.xml ïñ¶ «ôܾ† ç¬ðô£°‹ ÞîŸ è£ù Ý‚®M†® ç¬ðL¬ù à¼õ£‚è «õ‡ ´‹. HelloLNActivity -‚è£ù Gó™ -3 ™
  4. 4. <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Hallo, Lokalisierung</string> <string name="text_a">Soll ich dich einem Sommertag vergleichen,</string> <string name="text_b">Der du viel lieblicher und sanfter bist?</string> </resources> <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">Bonjour, Localisation</string> <string name="text_a">Irai-je te comparer au jour d'été?</string> <string name="text_b">Tu es plus tendre et bien plus tempéré.</string> </resources> - ªî£ì¼‹ ðì‹-11 ðì‹-14 ðì‹-13 Gó™-5Gó™-4 ªè£´‚èŠð†´œ÷¶. ªè£´‚èŠð†´œ÷ Gó™ ð†ìQŸ° H¡ùEJ¬ù ܬñˆF´‹. ð†ì¬ù AO‚ ªêŒî¾ì¡ Alert Dialog J¬ù  ªñ£N‚° ãŸð ñ£ŸP ܬñ‚èŠ «ð£õF™¬ô. Üîù£™ dialog-text Ýù¶ res/values/string/.xml â¡ø ç¬ðL™ àœ÷ îèõ¬ô 裇H‚°‹. ðì‹-7 ™ àœ÷¶ «ð£¡Á ªñ£N‚° ãŸð «î˜‰ªî´‚°‹ º¬øJ¬ù ܬñˆFì «õ‡´‹. ÜîŸè£ù õNº¬øè¬÷ 𣘊«ð£‹. ðì‹ 8-™ ªñ£N‚° ãŸð îèõ™èœ ⃰ «êI‚èŠðì «õ‡´‹ â¡ðî¬ù °P‚Aø¶. ꣡ø£è ªü˜ñ¡ ªñ£N‚° ãŸð õ®õ¬ñ‚è Local -code de-rDt â¡ðî¬ù ðò¡ð´ˆî «õ‡´‹. ªü˜ñQ‚° string.xml ç¬ðL¬ù res/ value-de â¡ø ç«ð£™ìK™ «êIˆFì «õ‡ ´‹. ºîL™ File>New>AndroidXML File â¡ð  «î˜‰ªî´‚è «õ‡´‹. (ðì‹-9) Ü´ˆ¶ Hó£ªü‚† â¡ð HelloL10N â¡ð¶ «î˜‰ªî´‚èŠð†®¼‚°‹. File â¡ð  String.xml â¡Á ªè£´‚è «õ‡´‹. H¡ ù˜ Language â¡ðî¬ù «î˜‰ªî´‚è «õ‡´‹. (ðì‹-10) H¡ù˜ Language â¡ø «î˜MŸ° de â¡Á ªè£´ ‚è «õ‡´‹. (ðì‹ 11) Þ‰î ªêò™Íô‹ªü˜ñ¡ ªñ£N‚è£ù String.xml «î£¡P»œ÷¶. ðòù£ ÷˜ ªü˜ñ¡ ªñ£NJ¬ù ªñ£Nò£è «î˜‰ªî´ˆ  â¡ù îèõ™èœ F¬óJ™ «î£¡ø «õ‡ ´‹ â¡ðî¬ù String. xml ªè£´‚è «õ‡´‹. Þî¬ù «ð£¡«ø fr (french) ñŸÁ‹ Ja (Japenese) ªñ£N‚° ༠õ£‚Aì «õ‡´‹. Þ‰î ªêò™Íô‹ res/values-de/strings/xml, res/values-fr/string.xml, res/values-ja/strings. xml ÝAò ç¬ð™èœ à¼õ£‚èŠð´‹. text-a ñŸÁ‹ text-b -‚è£ù ªñ£NJ¬ù «î˜‰ªî´‚ °‹ ªñ£N‚° ãŸð ñ£Á‹ Strings.xml Gó™ è¬÷ 𣘊«ð£‹. res/value-de/strings.xml-‚è£ù Gó™ Gó™ 4-™ ªè£´‚èŠð†´œ÷¶. res/values-fr/strings. xml-‚è£ù Gó™ 5-™ ªè£´‚èŠð†´œ÷¶. res/values-ja/strings.xml -‚è£ù Gó™ ðì‹ 12-™ 裇H‚èŠð†´œ÷¶. 嚪õ£¼ ªñ£N‚° ãŸð ªè£®J¬ù 裇H‚è Drawable ç«ð£™ìK¬ù à¼õ£‚è «õ‡´‹. German-res/drawable-de-rDE/flag.png French-res/drawable-fr-rFR/flag.png Canada-res/drawable-fr-rCA/Flag.png Japan-res/drawable-ja-rJP/flag.png Unitedstates-res/drawable-en-rUS/flag.png 嚪õ£¼ ªñ£N‚° ãŸø ®¡ ªè£® J¬ù ܉î‰î ç«ð£™ìK™ «êIˆFì «õ‡ ´‹. «êIˆî¾ì¡ ðì‹ 13-™ àœ÷¶ «ð£¡ø F¬ó «î£¡Á‹. ÞŠ«ð£¶ ÜŠO«èê¬ù ªêò™ð´ˆî Language â¡ðF™ Japan ªñ£N J¬ù «î˜‰ªî´ˆî£™ ðì‹ 14-™ àœ÷¶ «ð£¡Á F¬ó «î£¡Á‹.

×