From 5aa5e5c1317a1b40caace38e22b45d133007819b Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sat, 16 Jun 2018 12:44:46 +0000 Subject: [PATCH] I18N: Introduce unit tests for the Japanese language in order to facilitate future improvements. Props ryotsun Fixes #43829 git-svn-id: https://develop.svn.wordpress.org/trunk@43359 602fd350-edb4-49c9-b593-d223f7449a82 --- tests/phpunit/data/languages/ja_JP.mo | Bin 0 -> 658 bytes tests/phpunit/data/languages/ja_JP.po | 42 +++++++++++++++ tests/phpunit/tests/db.php | 2 +- tests/phpunit/tests/formatting/BlogInfo.php | 1 + tests/phpunit/tests/l10n.php | 56 +++++++++++++++++++- tests/qunit/fixtures/wp-api-generated.js | 9 ++-- 6 files changed, 105 insertions(+), 5 deletions(-) create mode 100644 tests/phpunit/data/languages/ja_JP.mo create mode 100644 tests/phpunit/data/languages/ja_JP.po diff --git a/tests/phpunit/data/languages/ja_JP.mo b/tests/phpunit/data/languages/ja_JP.mo new file mode 100644 index 0000000000000000000000000000000000000000..1399898aa789525109f1238c3ef93ad18f47541d GIT binary patch literal 658 zcma)(F;5gh6vqcSEY{dSVxz@aP?KVW8!S0e@SPF=_$tMiANsFU*BVl9=1g<@86lIC7q`HD=As8qA^ilgAZD| z3Gbcp*>;sn1U~P$HXqm!%OWeJ9%K^Hs$Px2bY1qqW_!k#60;oos+2`m8Kv>g8V*hE zq|RODpkfI7$a7_(kILvqftIBkViVpgN4a=IzfE`?MlBIO7jeX+RuaE_7QPC@V10Fc zS?qxI#)L=BFjz7gL8It?tZ0`%dZ8+$(rw-!O6veS+uaq>y7gJ9-5yx6totTcdXVr| zPhpT2wUvcfp=Mmdb#;}xPTc0#pB>Ggc6ihdcEwxJU?m!x@YF!AkjKrixfrC@jHoBE zn%|cAf>!o}H5yzk2UOrlX7AD<-RO!X3)1&L>6bi?y71K%*Jt1C5?zpG!UJ}3`el6Z dYkcs{-^%#&_sieMmp_l#NZuLu|6hfl{XYj=w)+48 literal 0 HcmV?d00001 diff --git a/tests/phpunit/data/languages/ja_JP.po b/tests/phpunit/data/languages/ja_JP.po new file mode 100644 index 0000000000..f71a737714 --- /dev/null +++ b/tests/phpunit/data/languages/ja_JP.po @@ -0,0 +1,42 @@ +# Translation of 5.0.x in Japanese +# This file is distributed under the same license as the 4.6.x package. +msgid "" +msgstr "" +"PO-Revision-Date: 2018-04-21 18:27+0900\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=n != 1;\n" +"X-Generator: Poedit 1.8.10\n" +"Project-Id-Version: 5.0.x\n" +"Language: ja_JP\n" + +#. translators: Translate this to the correct language tag for your locale, see +#. https://www.w3.org/International/articles/language-tags/ for reference. Do +#. not translate into your own language. +#: wp-includes/general-template.php:716 +msgid "html_lang_attribute" +msgstr "ja" + +#. translators: 'rtl' or 'ltr'. This sets the text direction for WordPress. +#: wp-includes/class-wp-locale.php:223 +msgctxt "text direction" +msgid "ltr" +msgstr "ltr" + +#. translators: $dec_point argument for https://secure.php.net/number_format, +#. default is . +#: wp-includes/class-wp-locale.php:215 +msgid "number_format_decimal_point" +msgstr "number_format_decimal_point" + +#. translators: $thousands_sep argument for +#. https://secure.php.net/number_format, default is , +#: wp-includes/class-wp-locale.php:202 +msgid "number_format_thousands_sep" +msgstr "number_format_thousands_sep" + +#. translators: %s: Plugin name and version +#: wp-includes/script-loader.php:620 +msgid "Update %s now" +msgstr "今すぐ %s を更新" diff --git a/tests/phpunit/tests/db.php b/tests/phpunit/tests/db.php index 5cfd3d4f53..4746d32be9 100644 --- a/tests/phpunit/tests/db.php +++ b/tests/phpunit/tests/db.php @@ -90,7 +90,7 @@ class Tests_DB extends WP_UnitTestCase { $current_locales = explode( ';', setlocale( LC_ALL, 0 ) ); // Switch to Russian - $flag = setlocale( LC_ALL, 'ru_RU.utf8', 'rus', 'fr_FR.utf8', 'fr_FR', 'de_DE.utf8', 'de_DE', 'es_ES.utf8', 'es_ES' ); + $flag = setlocale( LC_ALL, 'ru_RU.utf8', 'rus', 'fr_FR.utf8', 'fr_FR', 'de_DE.utf8', 'de_DE', 'es_ES.utf8', 'es_ES', 'ja_JP.utf8', 'ja_JP' ); if ( false === $flag ) { $this->markTestSkipped( 'No European languages available for testing' ); } diff --git a/tests/phpunit/tests/formatting/BlogInfo.php b/tests/phpunit/tests/formatting/BlogInfo.php index 3c6f03cbdf..8d513a3ccc 100644 --- a/tests/phpunit/tests/formatting/BlogInfo.php +++ b/tests/phpunit/tests/formatting/BlogInfo.php @@ -29,6 +29,7 @@ class Tests_Formatting_BlogInfo extends WP_UnitTestCase { array( 'de_DE_formal', 'de-DE-formal' ), array( 'oci', 'oci' ), array( 'pt_PT_ao1990', 'pt-PT-ao1990' ), + array( 'ja_JP', 'ja-JP' ), ); } diff --git a/tests/phpunit/tests/l10n.php b/tests/phpunit/tests/l10n.php index bb0f43d3ce..5173621d2c 100644 --- a/tests/phpunit/tests/l10n.php +++ b/tests/phpunit/tests/l10n.php @@ -53,7 +53,7 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertEmpty( $array ); $array = get_available_languages( DIR_TESTDATA . '/languages/' ); - $this->assertEquals( array( 'de_DE', 'en_GB', 'es_ES' ), $array ); + $this->assertEquals( array( 'de_DE', 'en_GB', 'es_ES', 'ja_JP' ), $array ); } /** @@ -97,6 +97,7 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertContains( '', $actual ); $this->assertContains( '', $actual ); $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); } /** @@ -120,6 +121,7 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertContains( '', $actual ); $this->assertContains( '', $actual ); $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); } /** @@ -141,6 +143,53 @@ class Tests_L10n extends WP_UnitTestCase { $this->assertContains( '', $actual ); $this->assertContains( '', $actual ); $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + } + + /** + * Add site default language to ja_JP in dropdown + */ + function test_wp_dropdown_languages_site_default_ja_JP() { + $args = array( + 'id' => 'foo', + 'name' => 'bar', + 'languages' => array( 'ja_JP' ), + 'translations' => $this->wp_dropdown_languages_filter(), + 'selected' => 'ja_JP', + 'echo' => false, + 'show_option_site_default' => true, + ); + $actual = wp_dropdown_languages( $args ); + + $this->assertContains( 'id="foo"', $actual ); + $this->assertContains( 'name="bar"', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + } + + /** + * Select dropdown language from de_DE to ja_JP + */ + function test_wp_dropdown_languages_ja_JP_selected() { + $args = array( + 'id' => 'foo', + 'name' => 'bar', + 'languages' => array( 'de_DE' ), + 'translations' => $this->wp_dropdown_languages_filter(), + 'selected' => 'ja_JP', + 'echo' => false, + ); + $actual = wp_dropdown_languages( $args ); + + $this->assertContains( 'id="foo"', $actual ); + $this->assertContains( 'name="bar"', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); + $this->assertContains( '', $actual ); } /** @@ -160,6 +209,11 @@ class Tests_L10n extends WP_UnitTestCase { 'native_name' => 'Italiano', 'iso' => array( 'it', 'ita' ), ), + 'ja_JP' => array( + 'language' => 'ja_JP', + 'native_name' => '日本語', + 'iso' => array( 'ja' ), + ), ); } diff --git a/tests/qunit/fixtures/wp-api-generated.js b/tests/qunit/fixtures/wp-api-generated.js index fd20726c9d..4e7c172421 100644 --- a/tests/qunit/fixtures/wp-api-generated.js +++ b/tests/qunit/fixtures/wp-api-generated.js @@ -2570,7 +2570,8 @@ mockedApiResponse.Schema = { "en_US", "de_DE", "en_GB", - "es_ES" + "es_ES", + "ja_JP" ], "description": "Locale for the user.", "type": "string" @@ -2697,7 +2698,8 @@ mockedApiResponse.Schema = { "en_US", "de_DE", "en_GB", - "es_ES" + "es_ES", + "ja_JP" ], "description": "Locale for the user.", "type": "string" @@ -2834,7 +2836,8 @@ mockedApiResponse.Schema = { "en_US", "de_DE", "en_GB", - "es_ES" + "es_ES", + "ja_JP" ], "description": "Locale for the user.", "type": "string"