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?