Merge "[BrowserTest] Fix i18n files lookup"

This commit is contained in:
jenkins-bot 2016-04-12 00:50:13 +00:00 committed by Gerrit Code Review
commit b779743208
2 changed files with 11 additions and 2 deletions

View file

@ -6,7 +6,12 @@ class VisualEditorPage
def self.translate(string)
language = ENV['LANGUAGE_SCREENSHOT_CODE']
file_name = (File.exist?("../../i18n/#{language}.json")) ? "../../i18n/#{language}.json" : '../../i18n/en.json'
file_name = File.expand_path("../../../i18n/#{language}.json", __dir__)
unless File.exist?(file_name)
file_name = File.expand_path('../../../i18n/en.json', __dir__)
end
json = JSON.parse(File.read(file_name))
json[string] || ''
end

View file

@ -10,6 +10,10 @@ module VisualEditorHelper
def i18n_file
language = lookup(:language_screenshot_code)
(File.exist?("i18n/#{language}.json")) ? "i18n/#{language}.json" : 'i18n/en.json'
file_name = File.expand_path("../../i18n/#{language}.json", __dir__)
unless File.exist?(file_name)
file_name = File.expand_path('../../i18n/en.json', __dir__)
end
file_name
end
end