diff options
-rw-r--r-- | lib/languages.rb | 2 | ||||
-rw-r--r-- | spec/lib/languages_spec.rb | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/lib/languages.rb b/lib/languages.rb index 7d03bc60a..4f51f9bee 100644 --- a/lib/languages.rb +++ b/lib/languages.rb @@ -32,6 +32,7 @@ class LanguageNames 'ce' => 'нохчийн мотт', 'ny' => 'chiCheŵa', 'zh' => '中文 (Zhōngwén)', + 'zh-HK' => '中文(香港)', 'cv' => 'чӑваш чӗлхи', 'kw' => 'Kernewek', 'co' => 'corsu', @@ -188,6 +189,7 @@ class LanguageNames 'zu' => 'isiZulu' } locale = locale.sub("_", "-") # normalize + return language_names[locale] if language_names[locale] main_part = I18n::Locale::Tag::Simple.tag(locale).subtags[0] return language_names[main_part] end diff --git a/spec/lib/languages_spec.rb b/spec/lib/languages_spec.rb new file mode 100644 index 000000000..38f611087 --- /dev/null +++ b/spec/lib/languages_spec.rb @@ -0,0 +1,22 @@ +# -*- encoding : utf-8 -*- +require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') + +describe LanguageNames do + + describe :get_language_name do + + it 'should return the name assigned to the language' do + LanguageNames.get_language_name('en').should == 'English' + end + + it 'should return the name assigned to the language when there is no specific location' do + LanguageNames.get_language_name('pt_BR').should == 'Português' + end + + it 'should return the name assigned to the language/location combination' do + LanguageNames.get_language_name('zh_HK').should == '中文(香港)' + end + + end + +end |