public function test_resolve_file_locale() { $locale = LocoAdmin::resolve_file_locale('/foo-en.po'); $this->assertEquals('en_GB', $locale->get_code()); $locale = LocoAdmin::resolve_file_locale('/foo-ja.po'); $this->assertEquals('ja_JP', $locale->get_code()); }
/** * Add any MO files for which PO files are missing */ private function add_mo(array $files, $domain = '') { foreach ($files as $mo_path) { $domain or $domain = LocoAdmin::resolve_file_domain($mo_path) or $domain = $this->get_domain(); $locale = LocoAdmin::resolve_file_locale($mo_path); $code = $locale->get_code() or $code = 'xx_XX'; if (isset($this->po[$domain][$code])) { // PO matched, ignore this MO // @todo better matching as PO may not be in same location as MO continue; } // add MO in place of PO, but only if locale code is valid if ('xx_XX' !== $code) { $this->add_file($mo_path) and $this->po[$domain][$code] = $mo_path; } } }
public function testUnknownThreeCharacterLanguageIgnored() { $locale = LocoAdmin::resolve_file_locale('/foo-th.po'); // If "foo" was treated as a language this would give invalid locale "foo_TH". $this->assertEquals('th', $locale->get_code(), '"foo" is not a valid langauge, but "th" is'); }