-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add translate_to_original method using original_backend (#56)
* Add translate_to_original method using original_backend * Debug failing CI * Store log artifacts * Add condition to always upload * Always assign original backend * Rename method * Check if table exists in CI * Inspect I18n backends * Set up Moirai migrations on CI * Force Backend chain in test env * Remove debugging from I18n_test --------- Co-authored-by: Alessandro Rodi <[email protected]>
- Loading branch information
1 parent
f2d2c28
commit 2fd7204
Showing
9 changed files
with
99 additions
and
6 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,6 @@ | |
* | ||
*= require_tree . | ||
*= require_self | ||
*= require translation_files | ||
*/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
td { | ||
height: 100px; | ||
width: 200px; | ||
vertical-align: top; | ||
} | ||
|
||
form { | ||
height: 100%; | ||
display: flex; | ||
align-items: stretch; | ||
} | ||
|
||
textarea.translation-textarea { | ||
width: 100%; | ||
height: auto; | ||
resize: vertical; | ||
min-height: 3em; | ||
overflow: hidden; | ||
margin-bottom: 0; | ||
} | ||
|
||
/*# TODO: this isn't coming through */ |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# frozen_string_literal: true | ||
|
||
module I18n | ||
class << self | ||
attr_accessor :original_backend | ||
end | ||
|
||
def self.translate_without_moirai(key, locale, **) | ||
raise "Original backend is not set" unless original_backend | ||
|
||
original_backend.translate(locale, key, **) | ||
end | ||
end |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class I18nExtensionsTest < ActiveSupport::TestCase | ||
test "it correctly translates using .translate and .translate_without_moirai" do | ||
assert_equal "Italienisch", I18n.t("locales.italian", locale: :de) | ||
|
||
Moirai::Translation.create!(locale: "de", key: "locales.italian", value: "Italianese") | ||
|
||
assert_equal 1, Moirai::Translation.count | ||
assert_equal "Italianese", I18n.t("locales.italian", locale: :de) | ||
assert_equal "Italienisch", I18n.translate_without_moirai("locales.italian", :de) | ||
end | ||
end |