📜 ⬆️ ⬇️

Quickly localize WordPress (part I)

Wordpress localisation If you have a blog or website spinning on WordPress and the language of the site is not English, then you have definitely encountered a localization problem.

WordPress has its own framework for translating the engine, as well as separate templates and plugins. We'll talk about this framework and convenient plug-ins in the second part.

But first, let's look at its shortcomings and how you can easily deal with them.
')
Some typical problems with system localization:



The solution to these problems through the code is quite simple. For example, in the new version of the template, you forgot to translate the word "Search ..." and you need to replace it with "Search ...".

By code this is solved like this:

  1. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  2. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  3. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  4. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  5. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  6. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  7. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }
  8. add_filter ( "gettext" , "my_gettext_filter" , 1000 , 3 ); function my_gettext_filter ( $new , $old , $domain ) { if ( "Search..." == $old ) { return "..." ; } else { return $new ; } }


But if there are several such patches, it’s inconvenient to climb each time into the code. Yes, and not necessary. Take the ready plugin Quick Localization . It is installed simply. Download the zip file and drop the quick-localization folder into wp-content / plugins or install the plugin directly through the admin panel.

Activate the plugin. Then we indicate which translation phrase should be replaced with our own:



We save. It seems everything.

The plugin has a lot of additional functionality. If you do not know which phrase is used and in which package (domain) of the translation, you can enable the debug search through the settings and look at the dump of all called translations.

Also in the Quick Localization plug-in, you can enable the collection of unknown translations, all, or on specified domains. The plugin will save them in drafts. You can translate the necessary, and remove the unnecessary with one click of a button.

Through the menu Export and Import, these translations can be easily transferred from site to site, as well as processed in any text editor.

The Russian translation of the plugin itself can be downloaded here as a text file and its contents go through the import page.

By the way, the Ukrainian news site Siohodni, which writes on the exotic Latin standard, managed to be completely localized after adding a total of 120 entries. 87 of them for standard WordPress and 26 for the Duster template. It took less than an hour. Transferring the same transfer to another site is less than a minute.

In the second part we will talk about tools and plugins that help automate WordPress translation in a longer standard way.

Source: https://habr.com/ru/post/143062/


All Articles