Zum Inhalt springen

Android Training/Supporting Different Languages/en: Unterschied zwischen den Versionen

Neue Version von externer Quelle importiert
(Neue Version von externer Quelle importiert)
 
(Neue Version von externer Quelle importiert)
 
(Eine dazwischenliegende Version desselben Benutzers wird nicht angezeigt)
Zeile 2: Zeile 2:
It’s always a good practice to extract UI strings from your app code and keep them in an external file. Android makes this easy with a resources directory in each Android project.
It’s always a good practice to extract UI strings from your app code and keep them in an external file. Android makes this easy with a resources directory in each Android project.


If you created your project using the Android SDK Tools (readCreating an Android Project), the tools create a <code>res/</code> directory in the top level of the project. Within this <code>res/</code> directory are subdirectories for various resource types. There are also a few default files such as <code>res/values/strings.xml</code>, which holds your string values.
If you created your project using the Android SDK Tools (read [[Special:MyLanguage/Android_Training/Creating_an_Android_Project|Creating an Android Project]]), the tools create a <code>res/</code> directory in the top level of the project. Within this <code>res/</code> directory are subdirectories for various resource types. There are also a few default files such as <code>res/values/strings.xml</code>, which holds your string values.


== Create Locale Directories and String Files ==
== Create Locale Directories and String Files ==
To add support for more languages, create additional <code>values</code> directories inside <code>res/</code> that include a hyphen and the ISO language code at the end of the directory name. For example, <code>values-es/</code> is the directory containing simple resourcess for the Locales with the language code "es". Android loads the appropriate resources according to the locale settings of the device at run time. For more information, see [http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources Providing Alternative Resource]s.
To add support for more languages, create additional <code>values</code> directories inside <code>res/</code> that include a hyphen and the ISO language code at the end of the directory name. For example, <code>values-es/</code> is the directory containing simple resourcess for the Locales with the language code "es". Android loads the appropriate resources according to the locale settings of the device at run time. For more information, see [http://developer.android.com/guide/topics/resources/providing-resources.html#AlternativeResources Providing Alternative Resources].


Once you’ve decided on the languages you will support, create the resource subdirectories and string resource files. For example:
Once you’ve decided on the languages you will support, create the resource subdirectories and string resource files. For example:
372

Bearbeitungen

Cookies helfen uns bei der Bereitstellung von Android Wiki. Durch die Nutzung von Android Wiki erklärst du dich damit einverstanden, dass wir Cookies speichern.