Jacob
Jacob

Reputation: 1225

android multilingual application

I try to translate my application to other languages. I added a few local files values/strings.xml to the project with relevant translation. The text is translated now, however it is not enough. There are 2 problems:

  1. In some languages the words are longer then in English and as a result text exceed the space. For example a few letters in the word on the button appear in second row.

Example in English Example in Russion

  1. I have a form with the fields 'from' and 'to'. In English they appear left to right, however in right to left languages they should appear right to left on the screen.

How I can solve those problems?

Upvotes: 1

Views: 68

Answers (1)

Sergey  Pekar
Sergey Pekar

Reputation: 8745

You can define other layout for right to left languages. You should place it to layout-<your language code>.

Also you can truncate and replace last chars of the string if it is too large. You can do this using android:ellipsize and android:singleLine attributes:

<TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/text_mytext"
        android:ellipsize="end"
        android:singleLine="true"
        />

Another way is to define text size in dimens.xml for needed languages and use it as follows:

in dimens.xml:

<dimen name="text_size">32sp</dimen>

in layout:

       <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:id="@+id/text_mytext"
        android:textSize="@dimen/text_size"
        />

Upvotes: 1

Related Questions