WordPress.org

Ready to get started?Download WordPress

Forums

Loco Translate
I do not see the saved translation on the site (11 posts)

  1. MrYann
    Member
    Posted 2 months ago #

    Hi,
    I'm new to this plugin. Everything is properly installed. I do not have any errors message. I can work on my translations. I can save them. The resulting .mo files seems to be properly saved to the server. However, I do not see my translations when I access the site. What I translate is a Theme I purchased. I Tried to clear my browser cache or use another browser but it's not working.

    Is there anyhting other than the wp-config language setting that needs to be done to activate the new translation file?

    Thanks.

    https://wordpress.org/plugins/loco-translate/

  2. timwhitlock
    Member
    Plugin Author

    Posted 2 months ago #

    If the MO files are valid the onus is on themes and plugins to configure themselves correctly. Loco can't help it if they're not, but perhaps a few things to try:

    Ensure your WPLANG setting is exact.
    If the file is called foo-fr_FR.mo make sure you set "fr_FR" as the language and not just "fr"

    Check Loco has named the files correctly and put them in the right place. It should do, but it also tries to guess what you meant to do when things aren't exactly as it expects, so potentially weird things can occur if files are in non-standard locations or with non-standard names.

    Check the theme is using its text domain properly and Loco has identified this in file names. style.css may contain a tag like "Text Domain: foo" this should then be used as the filename.

    Additionally the theme must pass "foo" in all its translation calls. Check the theme is doing these properly. You should see things like __('some text', 'foo')

    Check wordpress can see the MO file and is getting as far as even trying to load it. You can debug that in the core around here: https://github.com/WordPress/WordPress/blob/master/wp-includes/l10n.php#L455

    I should write this up somewhere.

  3. MrYann
    Member
    Posted 2 months ago #

    Thanks for your help. It gives me different things to look after. I'll contact the theme author to get some help also on that side to verify with your advices.

    I made a screen capture of my loco packages page. As you can see, we see 2 set of fr_FR links. However, on server, There is only one.

    https://drive.google.com/file/d/0B9ZaVefcvhW3T3dXNUYwclFRTUE/edit?usp=sharing

    Thanks.

  4. timwhitlock
    Member
    Plugin Author

    Posted 2 months ago #

    More strange is the MO file in the template column.
    Something strange going on there. I can't think of the top of my head how that could happen. You should only see POT files in that column.

    It's hard to help without seeing all the files, but this extra file might be something to do with it. Also check you're only using one Text Domain reference in the whole theme.

  5. MrYann
    Member
    Posted 2 months ago #

    HI,
    I asked help from the author, but nothing yet.

    On my end, I worked using your advices. It helped. Tee Text Domain was indeed not set anywhere. I created it and it cleaned what we see in the plugin settings:

    https://drive.google.com/file/d/0B9ZaVefcvhW3bG1BRDRzUkNrZ1E/edit?usp=sharing

    Since the text domain created is "neosense", I tried to rename the fr_FR.mo to neosense-fr_FR.mo. When I want to create a new language, loco see the the new file should begin by neosense. However, I still do not see any translation.

    HEre is a code example of a string to be translated and displayed:

    return str_replace('[…]', '<p><a href="'.get_permalink().'"><span>'.__( 'Read more', DPTPLNAME ).'</span></a></p>', $text); }

    [Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum's parser.]

    I entered debug code and I was able to validate that DPTPLNAME value is "neosense".

    Here is a sc of the translation menu. You can see the new neosense-fr_FR.mo file name and the fact that the String Read more is translated.:

    https://drive.google.com/file/d/0B9ZaVefcvhW3ekg2VWlHZ2xkSXc/edit?usp=sharing

    Do you see anything wrong in all of that?

    Thanks.

  6. timwhitlock
    Member
    Plugin Author

    Posted 2 months ago #

    I need to establish if this is a problem with Loco, or a problem with your theme.

    The only way I'll get to the bottom of it with such fragmented information is to get hold of all your working files. You can email a zip file to support-wp@localise.biz

    One thing to note is that themes only need the text domain in the file name when they're in the global languages directory. When they're bundled with the theme itself, they must not have the prefix. You can see this by examining the source of the load_theme_textdomain function. https://github.com/WordPress/WordPress/blob/master/wp-includes/l10n.php#L639-L644

  7. MrYann
    Member
    Posted 2 months ago #

    I sent you the package this morning.
    Thanks for your help.

  8. timwhitlock
    Member
    Plugin Author

    Posted 2 months ago #

    I have the file and will look at it tomorrow.

  9. timwhitlock
    Member
    Plugin Author

    Posted 2 months ago #

    I've looked at the files you've sent and I think the main problem is the file layout is simply a mess. Some files are prefixed when they shouldn't be, some are in the wrong place or in multiple places.

    You also have three namespaces being used, which although may not cause any technical problems, it's confusing. neosense is the text domain, but your files are named iguana and the PO file has an internal project name of Avanti.

    All you need is one template named correctly neosense.pot from which you can create a French file fr_FR.po and compile it to fr_FR.mo.

    I removed all the files that have at some point been duplicated into various locations and tested saving fr_FR.po tofr_FR.mo in the neosense/languages directory. then viewing the site with neosense theme enabled. It seems to work fine.

    I'm not ruling out you having experience a bug with Loco and files got put in the wrong place, but I can't reproduce any such error.

  10. MrYann
    Member
    Posted 2 months ago #

    Hi,
    Part of the mess is related to my tests. I tried different versions name and directories in case it would be grabed at somepoint.

    -I made some clean up with your advices. I deelted extra files

    -I edited iquana.po and changed Avanti to neosense inside the file

    -I renamed iguana to neosense.

    -I removed my Text Domain value froms style.css (Was added by me to try to force it to use the right file)

    -I made a few more translation, recompiled, sync, saved, tested. It was still not working. I then read about "then viewing the site with neosense theme enabled". The theme I use is Neosense Child. I tried directly with neosense and many strings translate correctly. Are you aware of any modifications that needs to be done when using a Child theme?

    Thanks.

  11. timwhitlock
    Member
    Plugin Author

    Posted 2 months ago #

    A child theme won't break parent theme textdomain loading unless it deliberately overrides it. Your child theme does nothing to load a text domain itself, so the parent neosense theme will load it via the load_theme_textdomainthat I mentioned above. You should debug this function call to see what it's doing and what it's trying to load.

    The neosense theme appears to load a custom configuration that it would appear you can alter in the admin area. This might be what's breaking your child theme translations. If the text domain is dynamically changed to anything other than 'neosense' it will be looking for another file.

    I'm afraid I can't identify any problem with the Loco plugin that is causing your issue.

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.