we use Angular extracted i18n into ARB files that looks like:
{
"@@locale": "en",
"1042662561872819815": " to ",
"@1042662561872819815": {
"description": "Used as a delimeter in a date range select, e.g. DATE1 to DATE2",
"x-locations": [
{
"file": "app/assets/javascripts/app/modules/date-time-inputs/date-range-input/date-range-input.component.html",
"start": { "line": "65", "column": "116" },
"end": { "line": "67", "column": "4" }
}
]
},
}
When importing such file to Crowdin, the description is picked up okay, but the âx-locationsâ are ignored. How to add information about the files names the string is used to âFile contextâ on import?
Youâre right, Crowdinâs standard ARB import ignores the x-locations array because itâs Angular-specific metadata, not a standard ARB context field. This means Crowdin wonât automatically map it to âFile context.â
Some possible solutions for adding x-locations as Context:
Pre-processing Script: This is the most flexible and recommended approach. Before uploading your ARB files, run a script to modify them. The script would extract the file and line from x-locations and inject this info into the stringâs description field (Crowdin does import the description).
Custom File Format: For more control, you could define a custom file format in Crowdin to specifically parse x-locations and map them to a context field. This requires a bit more setup.
In-Context Localization: While not using the x-locations data directly, integrating Crowdinâs In-Context tool into your Angular app provides the best visual context. Translators see strings live in your UI, which is often more valuable than a file path.
Hi @Dima, thank you for the recommendations. We went for the approach #1 and just mapping x-locations into description field, however, I see that in some cases when uploading new source strings using CLI, the context is not updated.
I believe this happens if I manually edit the context of a string and then try to upload a new context, the manually inputed context is not overriden. However, when uploading a new context for an âuntouchedâ string, the context is overriden as expected.
Seems like there is no way to make the string with manually inputed context be reset back to default state to allow the context to be overriden with one from uploaded source file.
How to do that?
@Natalia, thanks for your answer, but this does not help with the issue.
Even though I can rollback the context, the behavior is implicit. Please allow resetting the state manually without having to look though all of the logs.
Reproduction steps:
Upload a string with id âtestâ and context âtestâ using CLI
See the string in Crowdin, make sure it has context âtestâ
Upload a string with same id âtestâ and context âtest2â using CLI
See the same string in Crowdin, make sure the context was changed to âtest2â
Manually change the context string to âmanualâ in Crowdin
Upload a string with same id âtestâ and context âtest3â using CLI
See the same string in Crowdin, the string context is still âmanualâ (THE BUG IS HERE)
Thank you for providing the detailed reproduction steps. I contacted you by email as I need some extra details to review and reproduce this from my side.
As for now, please keep updating the strings context using the CLI approach.
In the meantime, if thereâs anything else I can assist you with, please let me know.
Hello! I decided to drop a reply here as well since other users might be interested.
This is not a bug, but an intentionally added feature. We have a âContext edited manuallyâ internal checkbox (under the hood) to prevent overwriting during an update if someone has manually changed it.
To make it work as you expect, you need to enable the save context information in files checkbox in the project settings:
Thanks,
The checkbox is checked, but still when pushing new source strings, manually edited contexts are not overridden.
The issue is about importing source strings and not exporting, so I donât get it, how does the checkbox in âExportâ settings affect import (file upload using CLI)?
Sorry for the confusion! Currently, if the context is edited in Crowdin, it cannot be changed during the update unless you change the source string as well. So, if during the update you change both the source text and context, it will get updated in the project.