-
Notifications
You must be signed in to change notification settings - Fork 0
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
- Loading branch information
1 parent
f2d2c28
commit aad85b6
Showing
8 changed files
with
90 additions
and
3 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
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_to_original(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,14 @@ | ||
# frozen_string_literal: true | ||
|
||
require "test_helper" | ||
|
||
class I18nExtensionsTest < ActiveSupport::TestCase | ||
test "it correctly translates using .translate and .translate_to_original" do | ||
assert_equal "Italienisch", I18n.t("locales.italian", locale: :de) | ||
|
||
Moirai::Translation.create!(locale: "de", key: "locales.italian", value: "Italianese") | ||
|
||
assert_equal "Italianese", I18n.t("locales.italian", locale: :de) | ||
assert_equal "Italienisch", I18n.translate_to_original("locales.italian", :de) | ||
end | ||
end |