Multi-languages json file

Hello !

I need advice on how to process a json file.

For the moment, my client does not want to send me the file, but he explained to me that he needs an output file with all the languages in it.

Like this : 

[
  {
    "Ref": "534976",
    "Langue": "FR",
    "Designation": "LAMPE ABAT JOUR BLANC SUR TREPIED BOIS",
    "SousDesignation": "Décoration d’intérieur, lampe à poser",
    "Description": "<p><span style="font-size:12px">Lampe sur trépied en bois avec abat-jour en tissu blanc. Idéale pour apporter une touche scandinave à votre déco intérieure ! </span></p>"
  },
{
    "Ref": "534976",
    "Langue": "SP",
    "Designation": "LÁMPARA PANTALLA BLANCA SOBRE TRÍPODE DE MADERA",
    "SousDesignation": "Decoración de interiores, lámpara de mesa",
    "Description": "<p><span style="font-size:12px">Lámpara trípode de madera con pantalla de tela blanca. ¡Ideal para aportar un toque escandinavo a la decoración de tu interior! </span></p>"
  },
{
    "Ref": "534976",
    "Langue": "EN",
    "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
    "SousDesignation": "Interior decoration, table lamp",
    "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
  }
]

is it possible ? how can I do this with Trados as I'll have 1 target file per language ?

Thanks for your help !

Isabelle



Tidying the code.
[edited by: Paul at 10:11 PM (GMT 0) on 1 Feb 2022]
emoji
Parents
  • You probably have two choices as far as I know:

    1. translate one language at a time, so you do the en-fr for example, then save the target file and use that file to do the en-sp, save the target file and now you have all three languages in one file.
    2. pre-process the file, translate, post-process the file.

    The first is self-explanatory and would be a lengthy process for a file with many languages.  The second would require a localization engineer who knew how to do this work... tools like Okapi Rainbow could be helpful here... but it would allow you to carry out the translation of each language simultaneously and eventually merge the files back into one.

    It's quite interesting because we created the multilingual XML filetype through our AppStore Team to be able to deal with this process and create a single multilingual xml file from a multilingual project.  We'll be tackling multilingual Excel next and I suppose there may be a niche for multilingual JSON too.  Perhaps something we'll put on our backlog and look at it if there is some demand.

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji
  • Hello Paul !

    Thanks for the answer ! As usal very clear and documented ! Slight smile

    For what I understand, choice 2 is too technical for us since we do not have a localization engineer. I tried to install Okapi Rainbow, but the installation crashed.

    I'll try to see what I can do with choice 1 : the only thing I would like to kow it's how can I ADD the translation (and not replace the source text) ? Is there a way to do this in Trados or should I prepare the file manually using a txt editor ?

    Thanks !

    emoji
  • 1 : the only thing I would like to kow it's how can I ADD the translation (and not replace the source text) ?

    It sounds as though the example you gave us is the final output, but the input should have only contained one language?  I thought it was te source file and you just needed to know how to get all the translated languages into one file.

    In this case you will need to add them prior to translating so you can overwrite the translatable text, and then follow choice 1.

    It sounds to me more and more as though it may be time to look at employing a localization engineer, or train someone up.  A truly valuable investment.

    For now, I guess a regex search and replace would do the trick as you could also do this with a batch process if you have many files.  A quick example...

    Take a source file like this:

    [
    {
        "Ref": "534976",
        "Langue": "EN",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
      {
        "Ref": "534977",
        "Langue": "EN",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
      {
        "Ref": "534978",
        "Langue": "EN",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      }
    ]

    Search for this:

    ({.+?"Langue":\s)("EN")(.+?}),?

    Replace with this:

    $1$2$3,\r\n$1"SP"$3,\r\n$1"FR"$3,

    Gets you this:

    [
    {
        "Ref": "534976",
        "Langue": "EN",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
    {
        "Ref": "534976",
        "Langue": "SP",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
    {
        "Ref": "534976",
        "Langue": "FR",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
      {
        "Ref": "534977",
        "Langue": "EN",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
    {
        "Ref": "534977",
        "Langue": "SP",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
    {
        "Ref": "534977",
        "Langue": "FR",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
      {
        "Ref": "534978",
        "Langue": "EN",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      },
    {
        "Ref": "534978",
        "Langue": "SP",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      },
    {
        "Ref": "534978",
        "Langue": "FR",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      },
    ]

    Then you just translate the file for each language as in choice 1.  Would that work?

    Is there a way to do this in Trados or should I prepare the file manually using a txt editor ?

    See above...

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji
Reply
  • 1 : the only thing I would like to kow it's how can I ADD the translation (and not replace the source text) ?

    It sounds as though the example you gave us is the final output, but the input should have only contained one language?  I thought it was te source file and you just needed to know how to get all the translated languages into one file.

    In this case you will need to add them prior to translating so you can overwrite the translatable text, and then follow choice 1.

    It sounds to me more and more as though it may be time to look at employing a localization engineer, or train someone up.  A truly valuable investment.

    For now, I guess a regex search and replace would do the trick as you could also do this with a batch process if you have many files.  A quick example...

    Take a source file like this:

    [
    {
        "Ref": "534976",
        "Langue": "EN",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
      {
        "Ref": "534977",
        "Langue": "EN",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
      {
        "Ref": "534978",
        "Langue": "EN",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      }
    ]

    Search for this:

    ({.+?"Langue":\s)("EN")(.+?}),?

    Replace with this:

    $1$2$3,\r\n$1"SP"$3,\r\n$1"FR"$3,

    Gets you this:

    [
    {
        "Ref": "534976",
        "Langue": "EN",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
    {
        "Ref": "534976",
        "Langue": "SP",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
    {
        "Ref": "534976",
        "Langue": "FR",
        "Designation": "WHITE SHADE LAMP ON WOODEN TRIPOD",
        "SousDesignation": "Interior decoration, table lamp",
        "Description": "<p><span style="font-size:12px">Wooden tripod lamp with white fabric shade. Ideal for bringing a Scandinavian touch to your interior decoration! </span></p>"
      },
      {
        "Ref": "534977",
        "Langue": "EN",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
    {
        "Ref": "534977",
        "Langue": "SP",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
    {
        "Ref": "534977",
        "Langue": "FR",
        "Designation": "BLACK SHADE DESKLAMP ON METAL TRIPOD",
        "SousDesignation": "Interior decoration, desk lamp",
        "Description": "<p><span style="font-size:12px">Metal tripod lamp with black fabric shade. Ideal for bringing darkening a bright day! </span></p>"
      },
      {
        "Ref": "534978",
        "Langue": "EN",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      },
    {
        "Ref": "534978",
        "Langue": "SP",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      },
    {
        "Ref": "534978",
        "Langue": "FR",
        "Designation": "BLUE SHADE LIGHT WITH HANGING FITTING",
        "SousDesignation": "Exterior decoration, hanging light",
        "Description": "<p><span style="font-size:12px">Exterior light with a blue waterproof shade. Ideal for matching your natural sunlight on those dark winter nights! </span></p>"
      },
    ]

    Then you just translate the file for each language as in choice 1.  Would that work?

    Is there a way to do this in Trados or should I prepare the file manually using a txt editor ?

    See above...

    Paul Filkin | RWS Group

    ________________________
    Design your own training!

    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

    emoji
Children