0

Wordpress is translated in romanian with diacritics. I want to display the translation without them and convert chars like ă,î,ț,ș in a,i,t,s because my font does not support them.

Is there any way to do this? Maybe there is an automated method in witch I can replace all characters in .po and .mo files?

My Wordpress setup includes WooCommerce.

yivi
  • 42,438
  • 18
  • 116
  • 138
Andrei
  • 121
  • 15
  • LOCO is not a good solution because I have to translate manually every string. – Andrei Mar 02 '17 at 13:56
  • Possible duplicate of [Replacing accented characters php](http://stackoverflow.com/questions/3371697/replacing-accented-characters-php) – yivi Mar 02 '17 at 14:06

1 Answers1

1

Connect to the server with SSH, go to languages folder and run the following commands:

for file in sh plugins/woocommerce-ro_RO.po; do ex -sc '%s/[Ă]/A/ge | %s/[ăâ]/a/ge | %s/[Ș]/S/ge | %s/ș/s/ge | %s/[Ț]/T/ge | %s/ț/t/ge | %s/Î/I/ge | %s/î/i/ge | x' "$file" ; done
msgfmt plugins/woocommerce-ro_RO.po -o plugins/woocommerce-ro_RO.mo

The first command edits the .po file and replaces all the diacritics inside that file and the second compiles the .po file in .mo file.

For msgfmt to work you need to have gettext installed.

For automation you can include all the commands that you need in a txt file (one per line) and run it like this:

sh remove-diacritics.txt

The commands were tested on macOS and CentOS.

Andrei
  • 121
  • 15