We have two separated codebases that are using different styles of localization. One of the codebases is using yaml, the other is using JSON.
Right now, we're slowly migrating to the codebase with JSON but with 20k yaml strings and 7 different languages it's a pain in the ass to convert this all manually. Unfortunately we're using string notation and not object notation in our yaml files so a converter like this wouldn't work.
Example yaml
cart.title.primary: Cart
cart.title.secondary: Buy products
cart.dialog.title: Remove product
cart.dialog.text: Are you sure to remove this product?
Becomes in a converter this
{
"cart.title.primary": "Cart",
"cart.title.secondary": "Buy products",
"cart.dialog.title": "Remove product",
"cart.dialog.text": "Are you sure to remove this product?"
}
But what I want, is for each dot in the string actually an object in JSON. So ideally, the yaml I provided should become something like:
{
"cart": {
"title": {
"primary": "Cart",
"secondary: "Buy Products"
},
"dialog": {
"title": "Remove product",
"text": "Are you sure to remove this product?"
}
}
}
Is there someone with experience doing something like this? Pref. using PHP or JavaScript. Thanks in advance!