Support » Fixing WordPress » How are .mo files used?

  • I currently have a dual language wordpress site, English and my native language. I use the Polylang plugin to obtain and manage the multilanguage functionality and everything works fine.

    There are however some harcoded strings that cannot be translated through the plugin’s interface. I am using the Vertex theme.

    An example is the 404 page template (no-results.php). Within that file there are 2 strings, enclosed in the esc_html_e() function (which I think is the Vertex’s version of __() function). Example:

    esc_html_e('No Results Found','Vertex');

    How can I display the above text in the right language based on the user’s prefference, using the theme’s .mo files? I already know that I can use get_bloginfo('language') but I would preffer not to use this method.

    I have already translated the above string in the theme’s .po file with PoEdit, and uploaded it back along with the new .mo as well, to no avail.

    Actually, I cannot understand how those .mo files are supposed to work.
    Can anybody explain it to me please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • esc_html_e(‘No Results Found’,’Vertex’);

    When you using this, this mean that the language will take on the Vertex theme, any String that in the tranlation of in the vertex will be displayed

    if you have your own, call the .po or else you then you can use this __(‘String Here’); and in the .po file is like
    'String Here', 'Your Translation' a newline indicates the for a single string

    That’s what is confusing. The translation inside the .mo file is not used, or I don’t know how should it be used.

    There are three types of files used for translation purpose.
    .pot (Portable Object Template)
    .po (Portable Object)
    .mo (Machine Object)

    Portable Object Template (POT) file:
    This file contains all the original strings of your theme.

    Portable Object (PO) file:
    PO file is the translation of POT file with msgstr sections in specific language.

    Machine Object (MO) file:
    MO file is the machine object file, which is binary of your language translation.

    In other words .pot file is just sample strings, .po file is a human readable file in which you write the specific translation against the msgstr and .mo file is for WordPress from where it reads the translation.

    Why is translation not working for you?

    There can be following possibilities that’s why translation is not working at your end.

    Are you following the correct naming convention of language file?
    For example you are translating theme in Arabic, file name should be vertex_ar.po and

    Are use using the correct domain name?
    esc_html_e('No Results Found','domain-name');
    You are using the domain name in “Vertex” instead of using “vertex”. Please verify domain name. It is written in lowercase.

    Are you updating the .mo file?
    After changing the .po file, please add this file in POEDIT and click update. It will update the .mo file.

    Please check the all above possibilities. Let us know if problem persists.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How are .mo files used?’ is closed to new replies.