remove i18nema and syck
fixes CNVS-34164 test plan: * basic smoke test that translations still work Change-Id: Ia88fc88de8b52aeaa92b65ea43b93eef5adb1dcc Reviewed-on: https://gerrit.instructure.com/95065 Tested-by: Jenkins Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Jon Jensen <jon@instructure.com> QA-Review: Jeremy Putnam <jeremyp@instructure.com> Product-Review: Cody Cutrer <cody@instructure.com>
This commit is contained in:
parent
bf93f5e050
commit
cfc2ef675f
|
@ -48,5 +48,4 @@ git_source(:github) do |repo_name|
|
|||
"https://github.com/#{repo_name}.git"
|
||||
end
|
||||
|
||||
gem 'syck', '1.0.4'
|
||||
gem 'iconv', '1.0.4'
|
||||
|
|
|
@ -50,7 +50,6 @@ gem 'hashery', '2.1.2', require: false
|
|||
gem 'highline', '1.7.8', require: false
|
||||
gem 'httparty', '0.14.0'
|
||||
gem 'i18n', '0.7.0'
|
||||
gem 'i18nema', '0.0.8'
|
||||
gem 'i18nliner', '0.0.12'
|
||||
gem 'icalendar', '1.5.4', require: false
|
||||
gem 'ims-lti', '2.1.0.beta.3', require: 'ims'
|
||||
|
|
|
@ -9,7 +9,6 @@ else
|
|||
load_path << (Rails.root + "config/locales/locales.yml").to_s # add it at the end, to trump any weird/invalid stuff in locale-specific files
|
||||
end
|
||||
|
||||
Rails.application.config.i18n.backend = I18nema::Backend.new
|
||||
Rails.application.config.i18n.enforce_available_locales = true
|
||||
Rails.application.config.i18n.fallbacks = true
|
||||
|
||||
|
@ -29,13 +28,13 @@ module DontTrustI18nPluralizations
|
|||
super
|
||||
end
|
||||
end
|
||||
I18nema::Backend.include(DontTrustI18nPluralizations)
|
||||
I18n::Backend::Simple.include(DontTrustI18nPluralizations)
|
||||
|
||||
module CalculateDeprecatedFallbacks
|
||||
def reload!
|
||||
super
|
||||
I18n.available_locales.each do |locale|
|
||||
if (deprecated_for = I18n.backend.direct_lookup(locale.to_s, 'deprecated_for'))
|
||||
if (deprecated_for = I18n.backend.send(:lookup, locale.to_s, 'deprecated_for'))
|
||||
I18n.fallbacks[locale] = I18n.fallbacks[deprecated_for.to_sym]
|
||||
end
|
||||
end
|
||||
|
@ -192,15 +191,15 @@ I18n.send(:extend, Module.new {
|
|||
alias :t :translate
|
||||
|
||||
def bigeasy_locale
|
||||
backend.direct_lookup(locale.to_s, "bigeasy_locale") || locale.to_s.tr('-', '_')
|
||||
backend.send(:lookup, locale.to_s, "bigeasy_locale") || locale.to_s.tr('-', '_')
|
||||
end
|
||||
|
||||
def fullcalendar_locale
|
||||
backend.direct_lookup(locale.to_s, "fullcalendar_locale") || locale.to_s.downcase
|
||||
backend.send(:lookup, locale.to_s, "fullcalendar_locale") || locale.to_s.downcase
|
||||
end
|
||||
|
||||
def moment_locale
|
||||
backend.direct_lookup(locale.to_s, "moment_locale") || locale.to_s.downcase
|
||||
backend.send(:lookup, locale.to_s, "moment_locale") || locale.to_s.downcase
|
||||
end
|
||||
})
|
||||
|
||||
|
|
|
@ -70,7 +70,7 @@ module I18nTasks
|
|||
|
||||
def complete_translations
|
||||
I18n.available_locales
|
||||
base = (I18n.backend.direct_lookup(language) || {})
|
||||
base = I18n.backend.send(:translations)[language.to_sym] || {}
|
||||
translations = base.flatten_keys.merge(new_translations)
|
||||
fix_plural_keys(translations)
|
||||
translations.expand_keys
|
||||
|
|
|
@ -8,10 +8,10 @@ namespace :i18n do
|
|||
Hash.send(:include, I18nTasks::HashExtensions) unless Hash.new.kind_of?(I18nTasks::HashExtensions)
|
||||
|
||||
def I18nliner.manual_translations
|
||||
I18n.backend.direct_lookup('en')
|
||||
I18n.available_locales
|
||||
I18n.backend.send(:translations)[:en]
|
||||
end
|
||||
|
||||
|
||||
puts "\nJS/HBS..."
|
||||
system "./gems/canvas_i18nliner/bin/i18nliner export"
|
||||
if $?.exitstatus > 0
|
||||
|
@ -79,11 +79,7 @@ namespace :i18n do
|
|||
I18n.load_path += Dir[Rails.root.join('gems', 'plugins', '*', 'config', 'locales', '*.{rb,yml}')]
|
||||
I18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}')]
|
||||
|
||||
require 'i18nema'
|
||||
|
||||
I18n.backend = I18nema::Backend.new
|
||||
I18nema::Backend.send(:include, I18n::Backend::Fallbacks)
|
||||
I18n.backend.init_translations
|
||||
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
|
||||
end
|
||||
|
||||
desc "Generates JS bundle i18n files (non-en) and adds them to assets.yml"
|
||||
|
@ -96,11 +92,11 @@ namespace :i18n do
|
|||
#
|
||||
# LOCALES=hi,ja,pt,zh-hans rake i18n:generate_js
|
||||
locales += ENV['LOCALES'].split(',').map(&:to_sym) if ENV['LOCALES']
|
||||
all_translations = I18n.backend.direct_lookup
|
||||
all_translations = I18n.backend.send(:translations)
|
||||
|
||||
# copy "real" translations from deprecated locales
|
||||
I18n.available_locales.each do |locale|
|
||||
if (deprecated_for = I18n.backend.direct_lookup(locale.to_s, 'deprecated_for'))
|
||||
if (deprecated_for = I18n.backend.send(:lookup, locale.to_s, 'deprecated_for'))
|
||||
all_translations[locale] = all_translations[deprecated_for.to_sym]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
|
||||
require "spec_helper"
|
||||
|
||||
require 'syck'
|
||||
require "yaml"
|
||||
|
||||
describe Utf8Cleaner do
|
||||
it "should strip out invalid utf-8" do
|
||||
|
@ -37,30 +37,4 @@ describe Utf8Cleaner do
|
|||
expect(Utf8Cleaner.strip_invalid_utf8(input)).to eq(output)
|
||||
end
|
||||
end
|
||||
|
||||
describe "YAML invalid UTF8 stripping" do
|
||||
it "should recursively strip out invalid utf-8" do
|
||||
data = YAML.load(<<-YAML)
|
||||
---
|
||||
answers:
|
||||
- !map:Hash
|
||||
id: 2
|
||||
text: t\xEAwo
|
||||
valid_ascii: !binary |
|
||||
oHRleHSg
|
||||
YAML
|
||||
answer = data['answers'][0]['text']
|
||||
expect(answer.valid_encoding?).to be_falsey
|
||||
Utf8Cleaner.recursively_strip_invalid_utf8!(data, true)
|
||||
expect(answer).to eq("two")
|
||||
expect(answer.encoding).to eq(Encoding::UTF_8)
|
||||
expect(answer.valid_encoding?).to be_truthy
|
||||
|
||||
# in some edge cases, Syck will return a string as ASCII-8BIT if it's not valid UTF-8
|
||||
# so we added a force_encoding step to recursively_strip_invalid_utf8!
|
||||
ascii = data['answers'][0]['valid_ascii']
|
||||
expect(ascii).to eq('text')
|
||||
expect(ascii.encoding).to eq(Encoding::UTF_8)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -15,7 +15,6 @@ Gem::Specification.new do |spec|
|
|||
spec.require_paths = ["lib"]
|
||||
|
||||
spec.add_dependency 'iconv', '~> 1.0'
|
||||
spec.add_dependency 'syck', '~> 1.0'
|
||||
|
||||
spec.add_development_dependency "bundler", "~> 1.5"
|
||||
spec.add_development_dependency "rake"
|
||||
|
|
|
@ -23,15 +23,6 @@
|
|||
# is switched to Psych. Otherwise we
|
||||
# won't have access to (safe|unsafe)_load.
|
||||
require 'yaml'
|
||||
|
||||
require 'syck' # so we can undo all the things before something else requires it
|
||||
if defined?(YAML::ENGINE)
|
||||
YAML::ENGINE.yamler = 'psych'
|
||||
else
|
||||
Object.send(:remove_const, :YAML)
|
||||
YAML = Psych # :/
|
||||
end
|
||||
|
||||
require 'safe_yaml'
|
||||
|
||||
module FixSafeYAMLNullMerge
|
||||
|
|
|
@ -22,7 +22,7 @@ describe I18n do
|
|||
context "_core_en.js" do
|
||||
it "should be up-to-date" do
|
||||
skip('RAILS_LOAD_ALL_LOCALES=true') unless ENV['RAILS_LOAD_ALL_LOCALES']
|
||||
translations = {'en' => I18n.backend.direct_lookup('en').slice(*I18nTasks::Utils::CORE_KEYS)}
|
||||
translations = {'en' => I18n.backend.send(:translations)[:en].slice(*I18nTasks::Utils::CORE_KEYS)}
|
||||
|
||||
# HINT: if this spec fails, run `rake i18n:generate_js`...
|
||||
# it probably means you added a format or a new language
|
||||
|
|
|
@ -27,8 +27,8 @@ describe "i18n js" do
|
|||
skip('USE_OPTIMIZED_JS=true') unless ENV['USE_OPTIMIZED_JS']
|
||||
skip('RAILS_LOAD_ALL_LOCALES=true') unless ENV['RAILS_LOAD_ALL_LOCALES']
|
||||
core_keys = I18nTasks::Utils::CORE_KEYS
|
||||
core_translations = Hash[I18n.available_locales.map(&:to_s).map do |locale|
|
||||
[locale.to_s, I18n.backend.direct_lookup(locale).slice(*core_keys)]
|
||||
core_translations = Hash[I18n.available_locales.map do |locale|
|
||||
[locale.to_s, I18n.backend.send(:translations)[locale].slice(*core_keys)]
|
||||
end].deep_stringify_keys
|
||||
|
||||
expect(driver.execute_script(<<-JS)).to eq core_translations
|
||||
|
|
|
@ -905,7 +905,7 @@ RSpec.configure do |config|
|
|||
end
|
||||
end
|
||||
|
||||
class I18nema::Backend
|
||||
class I18n::Backend::Simple
|
||||
def stub(translations)
|
||||
@stubs = translations.with_indifferent_access
|
||||
singleton_class.instance_eval do
|
||||
|
@ -923,8 +923,8 @@ class I18nema::Backend
|
|||
|
||||
def lookup_with_stubs(locale, key, scope = [], options = {})
|
||||
init_translations unless initialized?
|
||||
keys = normalize_keys(locale, key, scope, options[:separator])
|
||||
keys.inject(@stubs){ |h,k| h[k] if h.respond_to?(:key) } || direct_lookup(*keys)
|
||||
keys = I18n.normalize_keys(locale, key, scope, options[:separator])
|
||||
keys.inject(@stubs){ |h,k| h[k] if h.respond_to?(:key) } || lookup_without_stubs(locale, key, scope, options)
|
||||
end
|
||||
alias_method :lookup_without_stubs, :lookup
|
||||
|
||||
|
|
Loading…
Reference in New Issue