Skip to content

Commit

Permalink
Merge pull request #377 from flattenthecurve/import-language-fix
Browse files Browse the repository at this point in the history
Fix a small typo in import_language.rb
  • Loading branch information
matiasgarciaisaia authored Apr 28, 2020
2 parents 401f786 + 4f78863 commit 301ff9a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions import_language.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ def should_have_sci_review_notice(lang, section, translated_file, no_review_keys
end

def generate_content(lang, translations, no_review_keys: [])
FileUtils.rm_r(Dir[language_dir(translations_lang)], force: true)
FileUtils.rm_r(Dir[language_dir(lang)], force: true)

SECTIONS_TO_FILES.each do |section, source_file|
translated_file = source_file.sub("/en/", "/#{translations_lang}/")
translated_file = source_file.sub("/en/", "/#{lang}/")
translated_dir = File.dirname(translated_file)
FileUtils.mkdir_p(translated_dir)
File.open(translated_file, "w:UTF-8") { |file|
Expand All @@ -81,21 +81,21 @@ def generate_content(lang, translations, no_review_keys: [])
TOP_LEVEL_PAGES.each do |page, source_file|
source_content = File.open(source_file, 'r:UTF-8') { |f| f.read }
metadata = Metadown.render(source_content).metadata
metadata["lang"] = translations_lang
metadata["lang"] = lang
metadata["title"] = translations["#{page}-title"] if translations["#{page}-title"]
translated_file = source_file.sub(/-en.md$/, "-#{translations_lang}.md")
translated_file = source_file.sub(/-en.md$/, "-#{lang}.md")
File.open(translated_file, "w:UTF-8") { |file|
file.puts metadata.to_yaml
file.puts "---\n"
file.puts metadata["translate_content"] == false ? content_without_frontmatter(source_content) : translations[page]
}
end

translated_strings_dir = "_data/#{translations_lang}"
translated_strings_dir = "_data/#{lang}"
translated_strings = Hash[STRINGS.map { |key, value| [key, translations[key]] }]
FileUtils.mkdir_p(translated_strings_dir)
File.open("#{translated_strings_dir}/strings.yml", 'w:UTF-8') {|f| f.puts translated_strings.to_yaml }
NEW_LANGS << translations_lang unless SUPPORTED_LANGS.include? translations_lang
NEW_LANGS << lang unless SUPPORTED_LANGS.include? lang
end

def fetch_json_from_lokalise(lang: nil, filter_data: ['translated'])
Expand Down

0 comments on commit 301ff9a

Please sign in to comment.