Giter Site home page Giter Site logo

Comments (5)

dylanz avatar dylanz commented on July 1, 2024

Hello Jay! Could you show me a way to reproduce? I just created a blank 2.3.5 application, ran the tasks, created a model, and wasn't able to find any issues.

id: 93, raw_key: activerecord.errors.template.body, value: There were problems with the following fields:
id: 94, raw_key: activerecord.errors.template.header, value: 1 error prohibited this {{model}} from being saved
id: 95, raw_key: activerecord.errors.template.header, value: {{count}} errors prohibited this {{model}} from being saved

It seems like it grabbed those correctly. Shoot me an example, maybe console output if you can, and I'll be happy to help!

from i18n_backend_database.

jduff avatar jduff commented on July 1, 2024

If you add a call to the translate method that looks something like this:
I18n.t('activerecord.errors.messages.record_invalid', :errors => errors)
The rake task fails.

This could be a bit of an edge case, I'm not really sure.

from i18n_backend_database.

dylanz avatar dylanz commented on July 1, 2024

I just ran this command in console, and it worked fine:

I18n.t('activerecord.errors.messages.record_invalid', :errors => "test test test")
=> "Validation failed: test test test"

Then, I ran the "rake i18n:populate:all", and it ran without any errors.

Are there any more details you can provide? Can you show me what you database records look like?

from i18n_backend_database.

jduff avatar jduff commented on July 1, 2024

Doing that in the console and then running the rake task will do nothing since the task parses the application files to look for those calls. Drop that call into your app anywhere (view, controller, model) then running the rake task will fail.

Personally I don't really like the rake tasks and think it would be better to have a hook in the actual I18n.t call, if no translation is found it puts it into the database instead of parsing the files. Does that make sense?

from i18n_backend_database.

dylanz avatar dylanz commented on July 1, 2024

Perfect, I was able to replicate. The regular expression within the actual rake task is not pulling in the interpolation arguments it seems, which is a problem.

In regard to the rake tasks, you don't need to run them, and by default, if a translation does not exist for a given key, it is created. The rake tasks act as a way to bootstrap existing applications. For example, the application this was created for has many views that can be in many states, so manually triggering each translation was not an option. Using the tasks, we were able to auto-create about 10k+ translations that the translators could start working on immediately.

Thanks again for the heads up on this!

from i18n_backend_database.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.