phptransliteration

I need to display the language without diacritics in Wordpress


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.


Solution

  • 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.