Code Monkey home page Code Monkey logo

Comments (18)

bodrovis avatar bodrovis commented on June 2, 2024

Thank you for your feedback! I wanted to double-check, how your translations look on Lokalise? Specifically, how placeholders are represented there? Do you use universal Lokalise placeholders?

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

As a quick fix, you could try using Custom placeholders https://docs.lokalise.com/en/articles/5781985-custom-placeholders and Universal placeholders https://docs.lokalise.com/en/articles/1400511-lokalise-placeholders. For example, if your translation on Lokalise has the following contents:

Welcome, [%s:name]

Then you can enable Custom placeholders and provide the following data:

  • Starts with: %{
  • Ends with: }

Then use Ruby on Rails YAML format and Raw placeholder format when exporting your data.

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

Thanks @bodrovis ! We uploaded the YAML files from Ruby, and converted them to Universal Placeholders.

For example [%1$s:current_weather] currently. It’s [%1$s:current_temp].
image

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

We got access to the Custom Placeholders app, but it doesn't seem to format the data correctly when exported.

Set up with these settings:
image

And exported as Raw in YAML format, we still get Universal Placeholders in the export, like greeting: 'Hello [%1$s:recipient],'

It might be that the Custom Placeholders app needs to be enabled before we import the translations to Lokalise the first time? Sadly this is not possible for us as the keys are already uploaded and translated.

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

How does this gem usually work with a Rails project and rails-i18n, maybe you have an example project to show me?

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

Unfortunately I don't have any samples at hand, but let me try to double-check everything. It's strange because everything worked for me fine

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

Yeah you know it's not working with the placeholder you are currently using. However this approach is working fine

[%s:current_weather] currently. It’s [%s:current_temp]

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

Hi @bodrovis, are you suggesting that placeholder works in an en.yml file on Rails?

Doesn't seem to work for me on rails console:

I18n.backend.store_translations :en, { test_key: 'Example %{placeholder} here' }
I18n.translate('.test_key', placeholder: 'text')
=> "Example text here"

I18n.backend.store_translations :en, { test_key: 'Example [%s:placeholder] here' }
I18n.translate('.test_key', placeholder: 'text')
=> "Example [%s:placeholder] here"

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

No-no, here's an example.

Translation:

2022-08-17 19_56_54-Angular _ Lokalise β€” Mozilla Firefox

Configuration:
2022-08-17 19_57_15-Angular _ Lokalise β€” Mozilla Firefox

Download config:

2022-08-17 19_57_34-Angular _ Lokalise β€” Mozilla Firefox

Preview:

2022-08-17 19_57_52-Download Preview β€” Mozilla Firefox

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

So, effectively my universal placeholders are presented as ordinary RoR YAML placeholders when using "raw" format

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

Ah okay! There must be something wrong with how we uploaded our YAML files before, I assumed [%1$s:current_weather] was a universal placeholder processed by Lokalise.

Would you have a way to get this Rails gem working out-of-the-box with Lokalise? And without using the Custom Placeholders App so we don't need to fix all our translated strings (4k+) πŸ˜„

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

Actually [%1$s:current_weather] should work as a universal placeholder - I'm not quite sure what's the problem, to be honest (I've asked other team members to look into it).

Also, the gem should be working out of the box with translations similar to this one:

2022-08-17 20_09_35-Angular _ Lokalise β€” Mozilla Firefox

What was the original translation you tried to export?..

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

I've actually added another test case bodrovis/lokalise_manager@45ea245#diff-ffcc6c7c9aa007b1bd12983b91222c59ddcfe6917e2fd1cf6cef519f1edc8ee6R124

So, if I have the following translation Welcome to the app, %{username} on Lokalise, it gets exported as-is

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

Also, the gem should be working out of the box with translations similar to this one:

Could you explain how to get translations into Lokalise with those placeholders?

If I upload like this
image

with Convert to universal placeholders unchecked
image

I still get this result in the editor
image

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

I've actually added another test case bodrovis/lokalise_manager@45ea245#diff-ffcc6c7c9aa007b1bd12983b91222c59ddcfe6917e2fd1cf6cef519f1edc8ee6R124

And related to this, how did you get the placeholder %{username} to output in your new test on this line?

I see the request parameters in the VCR cassette have placeholder_format: icu defined, so I would expect {username} as that's what I was receiving.

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

I believe this is happening because you've enabled Custom placeholders. If you turn it off, you should see a plain old placeholder %{user_first_name}. Also, with the ICU format you'll get your %{} placeholders exported as-is because Lokalise doesn't detect those as placeholders at all - that's how it works in my test case

from lokalise_rails.

zachd avatar zachd commented on June 2, 2024

Okay I see, it's a bit of a hack then πŸ˜‰ If you changed the default of this gem to placeholder_format: raw it would make more sense.

Let me know if you get an answer from the team working on Custom Placeholders to support all types of Universal Placeholders and it should be good. A few lines in the documentation to explain that Universal Placeholders are only compatible with Rails if you use a Lokalise App would be great too!

from lokalise_rails.

bodrovis avatar bodrovis commented on June 2, 2024

Unfortunately I don't think there's any easy solution with Custom placeholders, universal ones and Rails. If you need this feature, I'd suggest reporting it to the customer support team and they can forward it to product guys (it would be more appropriate as I'm not a member of CS). Also, I'll update the docs for Rails.

In any case, thank you for reporting this and I'm sorry it tooks us a while to sort things out!

from lokalise_rails.

Related Issues (7)

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.