convert bad formatted number string with currency name to correct number format with translated currency name and propagate correctly

Hi,

I just had a job with a ton of lines with badly formatted numbers with currency name that needed to be translated while using correct formatting and according translation of currency. Is it possible to do this automated and have it propagated correctly?

EN > DE

2999 to 4000 dollar > 2.999 to 4.000 Dollar

8999 to 10000 leu > 8.999 to 10.000 Leu

So under TM settings you can set currencies and units and tell Studio how to handle them but Studio will then simply replace the same "symbol" in target but here we would need a translation as it's not a symbol per se but the currency.

The issue is that the numbers have a bad formatting so Studio does not recognise them as numbers to format to a currency format but simply propagates to numbers without correct formatting so I had to translate this line by line. :( With a few thousand lines with the same issue this was not very funny.

Br,

Pascal

emoji
Parents
  • For what I know you cannot do that from the TM settings, but it should be quite simple using regex. As my regex knowledge is not very much advanced, I would go for:

    search expression: (\d{1,3})?(\d{3}) to (\d{1,3})?(\d{3}) currency

    replace expression $1.$2 to $3.$4 currency

    This covers numbers from 1000 to 999999, however creates a problem with numbers below 1000. So depending on what you have more than one approach will be needed.

    But in case you have only this in your lines, the solution could be a combination of filtering and replacing. To make a better proposal I need more examples.

    emoji
  • Hi ,

    am still working on this one … so far I managed to get the regex refined so it would work with any numbers (lower than 1000 and higher than 999999) but it has the backdraw that I can't use back references to further replace the currency after the number (say add a space before the currency if the source string does not contain it):

    String: 100 to 10000000010 USD

    Regex: ([0-9](?=(?:[0-9]{3})+(?![0-9])))

    Backreference: $&.               (whereas the dot after & can be replaced by the character you need as thousand separator e.g. dot, comma, space, non-breaking space, narrow non-breaking space) BTW $0. or $1. as backreference will also work

    will give:

    100 to 10.000.000.010 USD

    emoji
Reply
  • Hi ,

    am still working on this one … so far I managed to get the regex refined so it would work with any numbers (lower than 1000 and higher than 999999) but it has the backdraw that I can't use back references to further replace the currency after the number (say add a space before the currency if the source string does not contain it):

    String: 100 to 10000000010 USD

    Regex: ([0-9](?=(?:[0-9]{3})+(?![0-9])))

    Backreference: $&.               (whereas the dot after & can be replaced by the character you need as thousand separator e.g. dot, comma, space, non-breaking space, narrow non-breaking space) BTW $0. or $1. as backreference will also work

    will give:

    100 to 10.000.000.010 USD

    emoji
Children