Last active
December 11, 2015 13:18
-
-
Save charger/4606053 to your computer and use it in GitHub Desktop.
TranslationStructure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TranslationStructure | |
attr_accessible :filename, :username, :comment | |
@filename | |
@languages | |
def initialize(filename, username, comment='') | |
@filename=filename | |
@username=username | |
@comment=comment | |
@languages={} | |
end | |
def add_data(section_name, translation_key, language_code, translation_text, downloaded_at=nil) | |
@sections[section_name][translation_key][TranslationProcessor.KEY_DOWNLOAD_AT][language_code]=downloaded_at unless downloaded_at.nil? | |
@sections[section_name][translation_key][language_code]=translation_text | |
@languages[language_code]='' | |
end | |
def sections | |
@sections | |
end | |
def languages | |
@languages.keys | |
end | |
end | |
#Пример использования | |
username=model.owner | |
time='2000-02-01 12:54:56.478241' | |
data= new TranslationStructure('city_valid.yml', username) | |
data.add_data('buildings', 'house', 'ru', 'Строение', time) | |
data.add_data('buildings', 'house', 'en', 'House', time) | |
data.add_data('buildings', 'dollars_genitive_forms', 'ru', ["бакса", "баксов", "баксов"], time) | |
data.add_data('buildings', 'dollars_genitive_forms', 'en', ["buks", "buks", "buks"], time) | |
TranslationProcessor.import_from_structure (data) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment