translation / rails Goto Github PK
View Code? Open in Web Editor NEWRails translation made _('simple').
Home Page: https://translation.io/rails
License: MIT License
Rails translation made _('simple').
Home Page: https://translation.io/rails
License: MIT License
I'm getting this error when trying to run bundle exec rake --trace translation:init
:
** Invoke translation:init (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
NoMethodError: undefined method `current=' for Locale:Module
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/gettext-3.2.2/lib/gettext.rb:274:in `set_current_locale'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/translation-1.9/lib/translation_io/railtie.rb:28:in `locale='
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/i18n-0.7.0/lib/i18n.rb:35:in `locale='
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/translation-1.9/lib/translation_io/railtie.rb:16:in `block in <class:Railtie>'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/lazy_load_hooks.rb:44:in `each'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/activesupport-4.2.8/lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/application/finisher.rb:62:in `block in <module:Finisher>'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `instance_exec'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:30:in `run'
/usr/local/opt/rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/railties-4.2.8/lib/rails/initializable.rb:55:in `block in run_initializers'
...
I tried disabling gettext, but it had no effect.
Ideas?
Ruby: 2.3.3
Rails: 4.2.8
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2018-12-01.
Gem::Specification#has_rdoc= called from /Users/eric/.rvm/gems/ruby-2.6.2/bundler/gems/translation-ff98468dc2da/translation.gemspec:13.
https://blog.rubygems.org/2011/03/28/1.7.0-released.html
https://blog.rubygems.org/2009/05/04/1.3.3-released.html
There doesn't seem to be any replacements, so I would suggest only removing the has_rdoc line.
When translating Spanish, everything seems to be working as expected. When translating to traditional Chinese (zh-Hant), no translations are picked up.
I created a project to repro the issue, but made it private out of general paranoya since the project I extracted it from is private. @aurels has access: https://github.com/InPlay/translation_bug_repro.
Here is the test from the repro project, traditional_chinese_test.rb
:
require 'minitest/spec'
require 'minitest/autorun'
require 'rails'
require 'translation'
TranslationIO.configure do |config|
config.api_key = ''
config.source_locale = 'en'
config.target_locales = ['zh-Hant', 'es']
config.locales_path = 'gettext'
end
describe 'When translating from English' do
it 'can translate "Sign In" to Spanish' do
TranslationIO::Proxy.current_locale = 'es'
TranslationIO::Proxy._("Sign Up").must_equal("Regístrese")
end
it 'can translate "Sign In" to Chinese' do
TranslationIO::Proxy.current_locale = 'zh_Hant'
TranslationIO::Proxy._("Sign Up").must_equal("報名")
end
end
Here's the output from running ruby traditional_chisese_test.rb
in the repro directory:
# Running:
.F
Finished in 0.007483s, 267.2868 runs/s, 267.2868 assertions/s.
1) Failure:
When translating from English#test_0002_can translate "Sign In" to Chinese [traditional_chisese_test.rb:24]:
Expected: "報名"
Actual: "Sign Up"
2 runs, 2 assertions, 1 failures, 0 errors, 0 skips
A small request for a --dry-run feature on sync_and_purge dry method.
Could be nice to get a list of which keys it wants to purge before actually doing it.
The YAML coming back from translation.io works fine but looks ugly. We're adding a post-processing step to the translation:sync
rake task that the loads and resaves the YAML to provide 80-character line wrapping. This both gets rid of most of the white space before closing quotes ('
) and switches to the more readable YAML folding style. In parallel, as mentioned in #13, we're deleting whitespace at the end of lines. The main code is:
filenames = Dir[Rails.root.join('config', 'locales', 'translation.*.yml')]
filenames.each do |filename|
IO.write(
filename, YAML.load_file(filename).to_yaml(line_width: 80)
.gsub(/ $/, '')
)
end
This produces diffs like:
- may_select_html: 'Sie können eines Ihrer GitHub Repositories <em>ODER</em> Informationen
- über ein anderes Projekt auswählen.
-
-'
+ may_select_html: >
+ Sie können eines Ihrer GitHub Repositories <em>ODER</em> Informationen über
+ ein anderes Projekt auswählen.
- url_of_homepage: 'Wie lautet die URL für die Projekt-Homepage (die URL für das
- Projekt als Ganzes)? Start mit http(s):// (viele Zeichen sind nicht erlaubt,
- einschließlich "?")
-
-'
+ url_of_homepage: >
+ Wie lautet die URL für die Projekt-Homepage (die URL für das Projekt als Ganzes)?
+ Start mit http(s):// (viele Zeichen sind nicht erlaubt, einschließlich "?")
line_width
is a poorly documented feature of the Psych YAML library.
Would you be open to a pull request that converts the 4 uses of to_yaml
in this translation gem to instead be to_yaml(line_width: 80)
?
What do you expect to happen?
Installed translation gem with bundle install.
created a app and added the config/initializers/translation.rb
ran bundle exec rake translation:init
and this actually produced a warning saying it could not find most of the translation YAML files (I believe it said) asking is this normal? etc and listed most of the locales I had listed in my initializer but I continued anyway.
Text should get translated to eg es
or ru
which is listed in my intializer. Also running locale -a
seems to list all translation.io locales.
locale -a
C
C.utf8
POSIX
af_ZA
af_ZA.utf8
am_ET
am_ET.utf8
ar_AE
ar_AE.utf8
ar_BH
...
What actually happened?
Text stays as default locale ie en
Code to reproduce
I18n.with_locale(:ru) do
puts I18n.locale
_('hello everyone, how are you today')
end
ru
hello everybody, how are you today
Version
translation (1.21)
gettext (~> 3.2, >= 3.2.5)
rails 6.0.0.1
ruby 2.6.5
Hello
Here is my configuration:
TranslationIO.configure do |config|
config.api_key = '...'
config.source_locale = 'en'
config.target_locales = %w[en]
# Uncomment this if you don't want to use gettext
config.disable_gettext = true
config.ignored_key_prefixes = %w[
time.formats demo
]
end
So, it's crashed on:
> rake translation:init
...
rake aborted!
JSON::ParserError: Empty input () at line 1, column 1 [parse.c:951] in '<!DOCTYPE html>
The only one place where I have it is:
mailer.html.erb
By the config I thought that it shouldn't go to views at all. So, why it goes? And how to fix?
I18n allows for custom fallbacks for each locale. It would be nice if this could be reflected in GetText. I don't think Locale supports multiple defaults or custom fallbacks, however it does support multiple current locales. You could simulate it with the following.
Locale.set_current(*I18n.fallbacks[I18n.locale])
Perhaps do this when overriding the I18n::Config.locale=
method in railtie.rb
?
Speaking of overriding locale=
you could add behavior in its own module and prepend
it to avoid duplicating the original method.
module TranslationIO::I18nConfigExtension
def locale=(*args)
super
if defined? Locale
Locale.set_current(*I18n.fallbacks[I18n.locale])
end
end
end
I18n::Config.prepend TranslationIO::I18nConfigExtension
Your documentation explain how to ignore specific keys, but what about a config to ignore specific files ?
If I write the following segments
example_one: It is equal to 3
example_two: It is > 3
example_three: It is too big
then the YAML that gets produced becomes
example_one: It is equal to 3
example_two: It is
> 3
example_three: It is too big
To get it the created YAML on one line, I can wrap the text in the segment in quotation marks, but then the produced YAML will become:
example_one: It is equal to 3
example_two: '"It is > 3"'
example_three: It is too big
Note the double quation marks. Is there any way to get the produced YAML on one line, like, example_two: It is > 3
, without it breaking into a new line?
Since I'm using gettext I tried to remove every other yml translation file. Long story short I couldn't.
The closest I got was to add the prefixes of keys on the ignored keys but I ended up with an empty translation.*.yml
and a populated localization.*.yml
.
Env info:
ruby 2.6.0p0
rails 5.2.1
translation (1.17)
gettext (~> 3.2, >= 3.2.5)
I'm looking for ways to reduce the in-memory usage of our app, and noticed translation is half the memory footprint of Rails itself!
Using https://github.com/schneems/derailed_benchmarks on my app, I found:
translation: 10.9258 MiB
gettext/tools: 6.9023 MiB
gettext/tools/msginit: 5.3867 MiB
locale/info: 4.582 MiB
locale/info/language: 4.4648 MiB
gettext/tools/msgmerge: 0.668 MiB (Also required by: gettext/tools)
text: 0.5313 MiB
gettext/tools/xgettext: 1.3164 MiB (Also required by: translation_io/railtie)
gettext/tools/parser/erb: 1.1445 MiB
gettext/tools/parser/ruby: 1.0977 MiB (Also required by: gettext/tools/xgettext)
irb/ruby-lex: 1.0039 MiB
irb/ruby-token: 0.457 MiB
gettext/po_parser: 2.1328 MiB (Also required by: gettext/tools/msgfmt, gettext/tools/msginit, and 3 others)
gettext: 0.8828 MiB (Also required by: gettext/tools/xgettext, gettext/tools/parser/glade, and 5 others)
locale: 0.4336 MiB (Also required by: gettext/tools/xgettext)
locale/tag: 0.3047 MiB
gettext/text_domain_manager: 0.4336 MiB (Also required by: translation)
gettext/text_domain: 0.3867 MiB
translation_io/client: 0.4961 MiB
For the running app, after it's been translated, is there anything I/we can cut? What is "locale/info/language" (4.4mb) and "gettext/po_parser" (2.1328mb)?
Thanks!
Request URL: https://translation.io/videos/rails.mp4
Request Method: GET
Status Code: 401 Unauthorized
I came across an issue while running rails translations:sync
recently:
ArgumentError: comparison of Pathname with String failed
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb:65:in `sort'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb:65:in `yaml_sources_reload_needed?'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb:47:in `reload_or_reuse_yaml_sources'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb:23:in `block in run'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb:20:in `each'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation/apply_yaml_source_edits_step.rb:20:in `run'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client/sync_operation.rb:26:in `run'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/client.rb:19:in `sync'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/translation-1.22/lib/translation_io/tasks.rb:23:in `block (2 levels) in <top (required)>'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/task.rb:273:in `block in execute'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/task.rb:273:in `each'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/task.rb:273:in `execute'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/bugsnag-6.7.3/lib/bugsnag/integrations/rake.rb:18:in `execute_with_bugsnag'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/task.rb:214:in `block in invoke_with_call_chain'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/2.3.0/monitor.rb:214:in `mon_synchronize'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/task.rb:194:in `invoke_with_call_chain'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/task.rb:183:in `invoke'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:160:in `invoke_task'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `each'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:116:in `block in top_level'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:125:in `run_with_threads'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:110:in `top_level'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/railties-5.2.4.4/lib/rails/commands/rake/rake_command.rb:23:in `block in perform'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/rake-12.3.3/lib/rake/application.rb:186:in `standard_exception_handling'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/railties-5.2.4.4/lib/rails/commands/rake/rake_command.rb:20:in `perform'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/railties-5.2.4.4/lib/rails/command.rb:48:in `invoke'
/Users/mlow/.rbenv/versions/2.3.7/lib/ruby/gems/2.3.0/gems/railties-5.2.4.4/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:11:in `require'
bin/rails:11:in `<main>'
Tasks: TOP => translation:sync
I did a little digging and it seems like Pathname
objects are being added to the I18n.load_path
somehow. In this case there were a couple:
String
with the same pathconfig/errors.yml
from that particular tag/versionThese files get added to the load path because File.exist?
and File.extname
can take in a String
or a Pathname
, so I'm not entirely sure what the best route is here. Let me know what you think!
After sync, I get empty localization.en.yml (comments only), and as result - rails throws error can not load translations from /usr/src/app/config/locales/localization.en.yml: expects it to return a hash, but does not
Generated file:
# THIS FILE CONTAINS LOCALIZATION KEYS : date and number formats, number precisions,
# number separators and all non-textual values depending on the language.
# These values must not reach the translator, so they are separated in this file.
#
# More info here: https://translation.io/blog/gettext-is-better-than-rails-i18n#localization
#
# You can edit and/or add new localization keys here, they won't be touched by Translation.io.
#
# If you want to add a new localization key prefix, use the option described here:
# https://github.com/translation/rails#custom-localization-key-prefixes
#
Rails expects it to be an empty hash, with locale key.
With the last version of this gem (1.33), on rails 6.1.7, ruby 2.7.5, nginx 1.20.2, passenger can't start the web server.
Here are the details of the error found in /var/log/nginx/error.log
:
App 23240 output: Error: The application encountered the following error: You have already activated forwardable 1.3.1, but your Gemfile requires forwardable 1.3.2. Since forwardable is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports forwardable as a default gem. (Gem::LoadError)
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/runtime.rb:309:in `check_for_activated_spec!'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/runtime.rb:25:in `block in setup'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/spec_set.rb:136:in `each'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/spec_set.rb:136:in `each'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/runtime.rb:24:in `map'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/runtime.rb:24:in `setup'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler.rb:151:in `setup'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/setup.rb:20:in `block in <top (required)>'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/ui/shell.rb:136:in `with_level'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/ui/shell.rb:88:in `silence'
App 23240 output: /usr/local/rvm/gems/ruby-2.7.5/gems/bundler-2.3.7/lib/bundler/setup.rb:20:in `<top (required)>'
App 23240 output: /usr/local/rvm/rubies/ruby-2.7.5/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:85:in `require'
App 23240 output: /usr/local/rvm/rubies/ruby-2.7.5/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:85:in `require'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb:380:in `activate_gem'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb:221:in `block in run_load_path_setup_code'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb:544:in `running_bundler'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb:220:in `run_load_path_setup_code'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/helper-scripts/rack-preloader.rb:91:in `preload_app'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/helper-scripts/rack-preloader.rb:189:in `block in <module:App>'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/ruby_supportlib/phusion_passenger/loader_shared_helpers.rb:397:in `run_block_and_record_step_progress'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/helper-scripts/rack-preloader.rb:188:in `<module:App>'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/helper-scripts/rack-preloader.rb:30:in `<module:PhusionPassenger>'
App 23240 output: /usr/local/rvm/gems/current-gems/gems/passenger-version/src/helper-scripts/rack-preloader.rb:29:in `<main>'
[ E 2022-11-11 23:11:53.9649 13906/T4q age/Cor/App/Implementation.cpp:221 ]: Could not spawn process for application /var/www/webroot/ROOT: The application encountered the following error: You have already activated forwardable 1.3.1, but your Gemfile requires forwardable 1.3.2. Since forwardable is a default gem, you can either remove your dependency on it or try updating to a newer version of bundler that supports forwardable as a default gem. (Gem::LoadError)
Error ID: 90d7c365
Error details saved to: /tmp/passenger-error-YXams6.html
forwardable
seems to be a dependence of gettext
so I'm uncertain if your gem is responsible for that (please note that I don't
use the gettext
gem, so parameter config.disable_gettext
is set to true
).
Currently, using = _('foo')
and = _("foo")
work, as well as =_ "foo"
and = _"foo"
, but not =_ 'foo'
nor = _'foo'
. The latter style won't be picked up, and it took a bit of investigation to figure out why.
https://github.com/aurels/translation-gem/blob/master/lib/translation_io/extractor.rb has a regex that, according to https://www.debuggex.com/r/fYSQ-jwQfTjhhE6T omits these cases.
It would be nice to have these fixed, or document their exclusion. For now, I'll be vigilant in using double-quotes and will put it in my own projects' documentation.
Oh, and thanks for a great service! I'm a very happy new user, otherwise :)
Ruby 2.6.6
Rails 6.1.4.1
translation: 1.27
With this code:
<%= _('jason test 1') %>
<% case 1 %>
<% end %>
<%= _('jason test 2') %>
Only jason test 1
appears in app.pot after a sync.
With this code:
<%= _('jason test 1') %>
<% case 1
end %>
<%= _('jason test 2') %>
Both jason test 1
and jason test 2
appear in app.pot.
_("Word")
gets picked up by the sync, but "#{_("Word")}"
does not. I tested this in both .rb and .erb files. It seems like this should work.
In our repo, we have disabled gettext support. However, running the sync produces:
$ rake translation:sync
* Downloading YAML source editions.
* Applying YAML source editions.
* Updating POT file.
* Generating POT file from YAML files.
* Saving new PO files.
* Creating new MO files.
* Saving new translation YAML files.
* Saving new localization YAML files (with non-string values).
* Collecting YAML localization entries
----------
Use this URL to translate: http://translation.io/david-a-wheeler/cii-best-practices-badge
----------
Shouldn't the middle 4 steps involving POT, PO and MO files be skipped?
Hi, running sync leaves my repo with a bunch of odd files:
$ rake translation:sync
cp -p config/locales/en.yml config/locales/en.yml.ORIG
* Downloading YAML source editions.
* Applying YAML source editions.
* Updating POT file.
* Generating POT file from YAML files.
* Saving new PO files.
* Creating new MO files.
* Saving new translation YAML files.
* Saving new localization YAML files (with non-string values).
* Collecting YAML localization entries
----------
Use this URL to translate: http://translation.io/david-a-wheeler/cii-best-practices-badge
----------
Removing bogus trailing whitespace (bug workaround).
cd config/locales/ && sed -i -e 's/ $//' *.yml && cd ../..
mv config/locales/en.yml.ORIG config/locales/en.yml
Now run: git commit -as -m 'rake translation:sync'
$ git status
M config/locales/.translation_io
M config/locales/translation.fr.yml
?? config/locales/en.yml-e
?? config/locales/localization.de.yml-e
?? config/locales/localization.fr.yml-e
?? config/locales/localization.ja.yml-e
?? config/locales/localization.zh-CN.yml-e
?? config/locales/translation.de.yml-e
?? config/locales/translation.fr.yml-e
?? config/locales/translation.ja.yml-e
?? config/locales/translation.zh-CN.yml-e
The first two (modified) files are just what I expect. But then all of the config/locales/*.yml-e
files shouldn't be there. Obviously, I delete them and may add an additional sync task to do so automatically.
But I thought I'd report this in case anyone else sees the same thing. I'm on OS X while my colleague on Linux doesn't this issue.
I have markdown in a haml file similar to the following (via my site's Terms of Service):
:markdown
These Terms of Service (**_“Terms”_**) govern your access to this website [...]
Here, it's finding Terms
to be a translation key. A workaround could be to switch the operators: __*"Terms"*__
, but I thought I'd bring up the issue so you're aware of it.
Note, we noticed because we translated our TOS into Spanish via terms_of_service.es.html.haml
, and it saw Términos
from **_"Términos"_**
. So, a separate issue might be that the gem should recognize es.html
as not being a source for english translation keys. In our case, though, fixing the main issue I'm bringing up would fix the es.html
-as-english issue.
Hello,
rake translation:sync rake task fails with: Psych::BadAlias: Unknown alias: male_first_name under Ruby 3.1.1.
YAML::load calls across sources need to be updated.
Example adjustment (if you want to support older and newer Psych with same gem version):
read_options = RUBY_VERSION >= "3.1.0" ? { :aliases => true } : {}
configurations = YAML.load(File.read(file_path, **read_options)
Thank you.
By policy our project doesn't allow files with whitespace errors, as determined by "git diff --check".
Unfortunately, "sync" creates .yml files with trailing whitespace. It's possible to fix it, but it's a pain, and I suspect many projects have this rule.
Could sync stop creating trailing whitespace?
Thanks so much! I only just started, but this does look like an interesting service.
FYI, here's the documentation from git diff --check:
--check
Warn if changes introduce whitespace errors. What are considered
whitespace errors is controlled by core.whitespace configuration.
By default, trailing whitespaces (including lines that solely
consist of whitespaces) and a space character that is immediately
followed by a tab character inside the initial indent of the line
are considered whitespace errors. Exits with non-zero status if
problems are found. Not compatible with --exit-code.
Hi guys,
I met the following issue today. I have a plural key for a number of students in English (source locale) in which it makes perfect sense:
students_count:
one: '1 student'
other: "%{count} students"
However, in order to have it translated into Arabic, I need to add a few more keys to the English translation file:
students_count:
zero: "0 students"
one: "1 student"
two: "2 students"
few: "%{count} students"
many: "%{count} students"
other: "%{count} students"
in order to have them appeared in Arabic locale in translations.io.
Could you suggest a way to avoid adding redundant keys to the English translation YML file?
Thanks,
Serhiy
Hi all,
I'd like to use translation.io to manage copy for A/B tests in my Rails project, and the custom languages feature seems ideal for this.
I've tried using custom locales with the syntax suggested in the README but,
What steps should I be taking to use custom languages?
Thanks,
Nuno
PS: excellent project.
Hi,
I have a file in a project that I do not want by any means to be translated by a person or the auto translate service.
So, I'm wondering if there is a way to exclude translation keys or files so that the keys/files will not be sent to translation.io and/or auto-translated.
Thanks!
Hey guys, this notice is cluttering my test output and logs with "do not set gettext locale because not loaded" messages. Is there a better way to present it?
when moving an existing project over to translation.io I uncommented config.disable_gettext = true
in the initialiser.
after running rake transition:init
some .po and .pot file are still generated in a new config/locales/gettext directory.
I expected those files not to be generated when clearly stating I do not use gettext
It seems this gem is using some code that is deprecated in Rails 6. I get this when I ran an rspec
with this gem loaded:
DEPRECATION WARNING: Initialization autoloaded the constants ActionText::ContentHelper and ActionText::TagHelper.
Being able to do this is deprecated. Autoloading during initialization is going
to be an error condition in future versions of Rails.
Reloading does not reboot the application, and therefore code executed during
initialization does not run again. So, if you reload ActionText::ContentHelper, for example,
the expected changes won't be reflected in that stale Module object.
These autoloaded constants have been unloaded.
Please, check the "Autoloading and Reloading Constants" guide for solutions.
See rails/rails#36546 for more.
I need to be able to do a global search and replace on all the locale translations. For example, turning all <i> into <em>. It would be great to support an upload to translation.io, as well as download from.
Currently , TranslationIO.configure
ends with a lot of methods added to Object
and delegated to Proxy
It is a code smell to add methods on Object, and may create lots of issues when using multiple translation system or migrating from one to another for example.
I would definitely prefer adding an include TranslationIO::Proxy
in my classes than having these methods magically inherited.
Would you consider adding a mechanism similar to disable_gettext
which would disable_object_monkey_patching
? Maybe even make that the default in a future major version change ?
Hi.
I have a problem with translations being cached.
Behaviour in rails console, works fine:
I18n.locale = :en
_('Dashboard')
=> "Dashboard"
I18n.locale = :lv
_('Dashboard')
=> "Sākums"
In controller action (via binding pry):
[1] pry> I18n.locale = "en"
=> "en"
[2] pry)> _('Dashboard')
=> "Dashboard"
[3] pry> I18n.locale = "lv"
=> "lv"
[4] pry> _('Dashboard')
=> "Dashboard"
There is no problem if locale is set only once per request (we do this in before action in base controller).
But in this controller action we need part of code within a block
I18n.with_locale(locale)
executed with different locale.
Inspecting I18n.locale
and GetText.locale
within the block we see that locale is switched correctly, but translations appear cached.
Calling ::GetText::TextDomainManager.clear_caches
does not help.
We had this problem a few weeks ago, I think it still applies.
When generating with languages like "da-DK", "de-DE" etc. Then the top element becomes "da", "de" etc.
We just changed it since...
# file: localization.da-DK.yml
...
# You can edit and/or add new localization keys here, they won't be touched by Translation.io.
...
When I run sync first time, everything looks ok:
* Downloading YAML source editions.
* Applying YAML source editions.
* Updating POT file.
* Generating POT file from YAML files.
* Sending data to server (it may take some time, please be patient).
* Saving new translation YAML files.
* Saving new localization YAML files (with non-string values).
* Collecting YAML localization entries from server.
----------
Use this URL to translate: https://translation.io/...
Then when I run sync again, it founds unused strings:
* Downloading YAML source editions.
* Applying YAML source editions.
* Updating POT file.
* Generating POT file from YAML files.
* Sending data to server (it may take some time, please be patient).
* Saving new translation YAML files.
* Saving new localization YAML files (with non-string values).
* Collecting YAML localization entries from server.
----------
2 keys/strings are in Translation.io but not in your current branch.
Execute "rake translation:sync_and_show_purgeable" to list these keys/strings.
----------
Use this URL to translate: https://translation.io/
These 2 key/stringsare already presented in my current codebase. But gem does not see them. But when I again run sync - it founds these strings again.
* Downloading YAML source editions.
* Applying YAML source editions.
* Updating POT file.
* Generating POT file from YAML files.
* Sending data to server (it may take some time, please be patient).
* Saving new translation YAML files.
* Saving new localization YAML files (with non-string values).
* Collecting YAML localization entries from server.
----------
Use this URL to translate: https://translation.io/...
Its like a circle (or loop): found/notfound/found/notfound etc...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.