Skip to content
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

Crowdin package doesn't handle parameters correctly #61

Open
JSBmanD opened this issue Nov 13, 2024 · 4 comments
Open

Crowdin package doesn't handle parameters correctly #61

JSBmanD opened this issue Nov 13, 2024 · 4 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@JSBmanD
Copy link

JSBmanD commented Nov 13, 2024

Describe the bug
When I create string in crowdin website with variable {business} inside text it creates arb file with string with such structure
"some_translation": "Discount for {business}"
As it's not structure, crowdin generator makes corrupted class
"some_translation": "Discount for {business}",
"@some_translation": {
"placeholders": {
"business": {
"type": "String"
}
}
},
image

To Reproduce
Steps to reproduce the behavior:

  1. Latest sdk (0.6.3)
  2. Create arb file:
{
  "@@locale": "en",
  "some_translation": "Discount for {business}"
}
  1. Generate class with
    fvm flutter gen-l10n
    fvm dart run crowdin_sdk:gen
  2. Try to run app
  3. See an error

Expected behavior
Generator makes not getter for this string but function with parameter that could be passed into as default intl generates
String some_translation(Object business);

Environment

  • Crowdin Flutter SDK: 0.6.3
  • Flutter version: 3.24.1
  • Dart version: bundled in flutter

Additional context
I'm using crowdin on the web to create strings

@JSBmanD JSBmanD added the bug Something isn't working label Nov 13, 2024
@andrii-bodnar andrii-bodnar added the help wanted Extra attention is needed label Nov 14, 2024
@FlutterOd
Copy link
Collaborator

Hi @JSBmanD

Since in Steps to reproduce you use .arb file with the string without any placeholders - it's expected behaviour that Flutter SDK generates simple getter.

Could you please clarify what do you get in your .arb files from Crowdin website?

For translation with variable in your .arb file you should receive such structure:
"some_translation": "Discount for {business}", "@some_translation": { "placeholders": { "business": { "type": "String" } } },

And with such structure Flutter SDK generates function with parameter

@JSBmanD
Copy link
Author

JSBmanD commented Nov 25, 2024

@FlutterOd i'm using this placeholder {business}. I know that metadata structure is a preferable way of using vars but flutter can generate func with param from simple placeholder (using intl generation). Is it possible to create string with correct placeholder in crowdin web?

@FlutterOd
Copy link
Collaborator

@JSBmanD

Currently Crowdin doesn't have mechanism to generate structure with placeholders when you add new strings with Crowdin UI.

To manage strings with variables we recommend to add them in your Flutter project .arb file with needed placeholders and then update the source file in Crowdin.

We will consider supporting simple strings with variables (without placeholder structure) on SDK side in the future

@JSBmanD
Copy link
Author

JSBmanD commented Nov 25, 2024

@FlutterOd the problem is more on a crowdin package. Because intl_utils supports generating translation with variable even though i don't have metadata property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants