-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Problems with multiple domains setup #176
Comments
idk ... don't remember the details of how this is supposed to work :(
... I'd recommend opening up the gem to drop a few debugs/puts to find out
where it's going wrong, please report your findings back here :)
…On Tue, Aug 7, 2018 at 11:18 PM MamesPalmero ***@***.***> wrote:
I am trying to configure gettext_i18n_rails to use multiple domains, as
it says in the configuration. Here is my current configuration:
*config/initializers/fast_gettext.rb*
FastGettext.add_text_domain 'app', path: 'locale', type: :po
FastGettext.add_text_domain 'errors', path: 'locale', type: :po
FastGettext.default_available_locales = ['en', 'es'']
FastGettext.default_text_domain = 'app'
Object.send(:include, FastGettext::TranslationMultidomain)
*lib/task/gettext.rake*
Rake::Task["gettext:setup"].clear
namespace :gettext do
task :setup => [:environment] do
FastGettext.translation_repositories.each_key do |domain|
GetText::Tools::Task.define do |task|
task.package_name = domain
task.package_version = "1.0.0"
task.domain = domain
task.po_base_directory = locale_path
task.mo_base_directory = locale_path
task.files = files_to_translate
task.enable_description = false
task.msgmerge_options = gettext_msgmerge_options
task.msgcat_options = gettext_msgcat_options
task.xgettext_options = gettext_xgettext_options
end
end
end
end
*and in any file of my project app/.../*.rb*
d_("errors", "Error")
The problem is that after adding the languages and executing rake
gettext: find, the .pot and .po files are generated empty. I think the
locale/errors.pot andlocale/language/errors.po files should have an entry
with msgid 'error". Is there something wrong with my configuration or
something that I did not understand correctly?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#176>, or mute the
thread
<https://github.com/notifications/unsubscribe-auth/AAAsZ0gZd7YnQoXKn_wrSddBZmoNzKAqks5uOb3rgaJpZM4VyeRt>
.
|
I've got the same issue and tried to follow the code as much as I could before I started getting lost. I am assuming that the parser (based on my research) isn't including the multidomain methods that are used to translate. I'm happy to open a PR if I can be pointed in the right direction. I'm not sure it's even this gem that needs to be updated to support it. |
sorry no idea ... just erm dig in and add docs / refactor things that are unclear on the way :( |
It seems the problem is in def process_call exp
_call = exp.shift
_recv = process exp.shift
meth = exp.shift
case meth
when :_, :p_, :N_, :pgettext, :s_
gettext_simple_call(exp)
when :n_
gettext_plural_call(exp)
end
until exp.empty? do
process(exp.shift)
end
s()
end This method seems to specifically ignore calls such as _('foo')
D_('bar') The above code will only find the first translation. If you change it to the following: def process_call exp
_call = exp.shift
_recv = process exp.shift
meth = exp.shift
case meth
when :_, :p_, :N_, :pgettext, :s_, :d_, :D_
gettext_simple_call(exp)
when :n_
gettext_plural_call(exp)
end
until exp.empty? do
process(exp.shift)
end
s()
end It will find both, producing: [["foo", "/tmp/test.rb:1"], ["bar", "/tmp/test.rb:2"]] Having said that, I'm not sure if this output is what is expected when using multi domain translation strings. |
I don't remember touching / seeing this ... can you make a PR with the change you think is best 🤷♂️ |
@grosser Unfortunately, I'm not sure if these changes would even be correct as I'm not familiar with what output is expected by the code that makes use of the above code. |
can you come up with a test-case that fails now ? ... so we have something concrete that can be fixed by poking in the code |
I am trying to configure
gettext_i18n_rails
to use multiple domains, as it says in the configuration. Here is my current configuration:config/initializers/fast_gettext.rb
lib/task/gettext.rake
and in any file of my project app/.../*.rb
d_("errors", "Error")
The problem is that after adding the languages and executing
rake gettext: find
, the.pot
and.po
files are generated empty. I think thelocale/errors.pot
andlocale/language/errors.po
files should have an entry withmsgid 'error"
. Is there something wrong with my configuration or something that I did not understand correctly?The text was updated successfully, but these errors were encountered: