Intro to Android

Lab: Internationalization

Let's add Japanese numbers!

Create a folder values-ja and a strings file under this directory.

Copy the characters from here into your strings.xml folder for keys 0-9:

Add tests

Robolectric allows you configure the qualifiers for a specific test:

@Config (qualifiers = "ja")
public void shouldHaveJa0Key()
    verifyKey(, R.string.key0, "零");

I have a helper function to reduce the duplicated code for each key. You could refactor this even further into an array that you loop through to verify each button.

    Button key = (Button) buttonFragment.getView()
                                        .findViewById( id );
    assertViewIsVisible( key );

    String resourceString = getString( stringId );
    assertThat( key.getText().toString(),
                equalTo( resourceString ) );
    assertThat( expectedString,
                equalTo( resourceString ) );

Build and change your device's language to Japanese to visually verify the internationalization worked.