Permalink
Browse files

keep locale names in translations so they can be translated, too

  • Loading branch information...
1 parent 1b0a16d commit a7b900fea4d5d250374f289fd76503e4516a07a7 @mislav committed Jul 27, 2010
Showing with 52 additions and 52 deletions.
  1. +3 −3 app/helpers/tolk/application_helper.rb
  2. +1 −49 app/models/tolk/locale.rb
  3. +48 −0 config/locales/en-locales.yml
View
6 app/helpers/tolk/application_helper.rb
@@ -19,10 +19,10 @@ def yaml_value(value)
end
def tolk_locale_selection
- existing_locale_names = Tolk::Locale.all.map(&:name)
+ existing_locales = Tolk::Locale.all.map(&:name)
- pairs = Tolk::Locale::MAPPING.to_a.map(&:reverse).sort_by(&:first)
- pairs.reject {|pair| existing_locale_names.include?(pair.last) }
+ pairs = I18n.translate(:locales).invert.to_a.sort_by(&:first)
+ pairs.reject {|pair| existing_locales.include?(pair.last.to_s) }
end
def scope_selector_for(locale)
View
50 app/models/tolk/locale.rb
@@ -5,54 +5,6 @@ module Tolk
class Locale < ActiveRecord::Base
set_table_name "tolk_locales"
- MAPPING = {
- 'ar' => 'Arabic',
- 'bs' => 'Bosnian',
- 'bt' => 'Bulgarian',
- 'ca' => 'Catalan',
- 'cz' => 'Czech',
- 'da' => 'Danish',
- 'de' => 'German',
- 'dsb' => 'Lower Sorbian',
- 'el' => 'Greek',
- 'en' => 'English',
- 'es' => 'Spanish',
- 'et' => 'Estonian',
- 'fa' => 'Persian',
- 'fi' => 'Finnish',
- 'fr' => 'French',
- 'he' => 'Hebrew',
- 'hr' => 'Croatian',
- 'hsb' => 'Upper Sorbian',
- 'hu' => 'Hungarian',
- 'id' => 'Indonesian',
- 'is' => 'Icelandic',
- 'it' => 'Italian',
- 'ja' => 'Japanese',
- 'ko' => 'Korean',
- 'lo' => 'Lao',
- 'lt' => 'Lithuanian',
- 'lv' => 'Latvian',
- 'mk' => 'Macedonian',
- 'nl' => 'Dutch',
- 'no' => 'Norwegian',
- 'pl' => 'Polish',
- 'pt-BR' => 'Portuguese (Brazilian)',
- 'pt-PT' => 'Portuguese (Portugal)',
- 'ro' => 'Romanian',
- 'ru' => 'Russian',
- 'se' => 'Swedish',
- 'sk' => 'Slovak',
- 'sl' => 'Slovenian',
- 'sr' => 'Serbian',
- 'sw' => 'Swahili',
- 'th' => 'Thai',
- 'tr' => 'Turkish',
- 'uk' => 'Ukrainian',
- 'vi' => 'Vietnamese',
- 'zh' => 'Chinese'
- }
-
has_many :phrases, :through => :translations, :class_name => 'Tolk::Phrase'
has_many :translations, :class_name => 'Tolk::Translation', :dependent => :delete_all
accepts_nested_attributes_for :translations, :reject_if => proc { |attributes| attributes['text'].blank? }
@@ -193,7 +145,7 @@ def primary?
end
def language_name
- MAPPING[self.name] || self.name
+ I18n.translate(self.name, :scope => :locales, :default => self.name)
end
def [](key)
View
48 config/locales/en-locales.yml
@@ -0,0 +1,48 @@
+:en:
+ :locales:
+ :uk: Ukrainian
+ :it: Italian
+ :"no": Norwegian
+ :ja: Japanese
+ :hsb: Upper Sorbian
+ :fr: French
+ :de: German
+ :cz: Czech
+ :sk: Slovak
+ :hu: Hungarian
+ :zh: Chinese
+ :zh-TW: Chinese (Traditional)
+ :sl: Slovenian
+ :ru: Russian
+ :lo: Lao
+ :fi: Finnish
+ :es: Spanish
+ :sw: Swahili
+ :ko: Korean
+ :et: Estonian
+ :id: Indonesian
+ :fa: Persian
+ :pt-PT: Portuguese (Portugal)
+ :pt-BR: Portuguese (Brazilian)
+ :pl: Polish
+ :bs: Bosnian
+ :ar: Arabic
+ :se: Swedish
+ :ro: Romanian
+ :he: Hebrew
+ :el: Greek
+ :da: Danish
+ :bt: Bulgarian
+ :vi: Vietnamese
+ :tr: Turkish
+ :nl: Dutch
+ :mk: Macedonian
+ :lt: Lithuanian
+ :dsb: Lower Sorbian
+ :ca: Catalan
+ :th: Thai
+ :sr: Serbian
+ :en: English
+ :lv: Latvian
+ :is: Icelandic
+ :hr: Croatian

0 comments on commit a7b900f

Please sign in to comment.