class Twine::TwineDefinition
Attributes
comment[RW]
ios_comment[RW]
key[R]
reference[RW]
reference_key[RW]
translations[R]
Public Class Methods
new(key)
click to toggle source
# File lib/twine/twine_file.rb, line 11 def initialize(key) @key = key @comment = nil @ios_comment = nil @tags = nil @translations = {} end
Public Instance Methods
raw_comment()
click to toggle source
# File lib/twine/twine_file.rb, line 23 def raw_comment @comment end
raw_ios_comment()
click to toggle source
# File lib/twine/twine_file.rb, line 31 def raw_ios_comment @ios_comment end
translation_for_lang(lang)
click to toggle source
# File lib/twine/twine_file.rb, line 56 def translation_for_lang(lang) translation = [lang].flatten.map { |l| @translations[l] }.first translation = reference.translation_for_lang(lang) if translation.nil? && reference return translation end
translation_for_lang_or_nil(lang, dev_lang)
click to toggle source
Twine
adds a copy of the dev language's translation if there is no definition provided for the language, which is useful in the main Localizable.strings file because iOS doesn't auto use the Base language's value, but we don't want that behaviour in our plurals
# File lib/twine/twine_file.rb, line 67 def translation_for_lang_or_nil(lang, dev_lang) translation = [lang].flatten.map { |l| @translations[l] }.first # translation never comes back as nil because Twine fills with the dev_lang string if lang != dev_lang [lang].flatten.map do |l| if @translations[l] == @translations[dev_lang] return nil end end end return translation end