• Resolved maps1990

    (@maps1990)


    Hi,

    When I started using Loco I saw everywhere on internet that instead of editing the Woocommerce file, one had to Copy it, in order to avoir loosing all changes with each Woocommerce update.

    It has been running smoothly for a year, but today I saw that a string was missing from my copied file, but was present in the original file. Further investigation showed me that currently the original file has around 7400 strings while my copy made in 2019 has only 6000.

    –> I guess with every Woocommerce update, the original file is updated too, and not my copy. What can I do to add the missing 1400 strings to my copy so that I can translate them? I could make a new copy but I would loose all my current translations.

    I hope the issue is clear, otherwise please let me know.

    Thank you,
    M

Viewing 15 replies - 1 through 15 (of 16 total)
  • Plugin Author Tim W

    (@timwhitlock)

    I guess with every Woocommerce update, the original file is updated too, and not my copy.

    Correct. WordPress will update installed translation files, but not any custom translation files stored elsewhere. Loco Translate does not automatically update any files ever. This is on purpose.

    What can I do to add the missing 1400 strings to my copy so that I can translate them?

    This is what the Sync function is for. It will sync your custom PO files to woocommerce.pot (or to another PO file if you asked it to). See working with templates.

    Thread Starter maps1990

    (@maps1990)

    Hi Tim,

    Thank you, that helps a lot. One last thing: when synchronizing, the translations to my language of the 1400 new strings were also synced (whereas my copy was initially empty, I had just translated a couple dozens of string out of the 6000) so it makes it harder to know which strings are my translations and which just got downloaded from the template.

    Is there a way to add the newly synced strings only in the their original language, with empty translations slots? Or alternatively, a way to tag mine? The aim for me is just to keep track of what I translated and what was synced from the author.

    Best,
    M

    • This reply was modified 4 years, 8 months ago by maps1990.
    Plugin Author Tim W

    (@timwhitlock)

    Translations are not copied during sync. It only updates available source strings.

    Thread Starter maps1990

    (@maps1990)

    Hi Tim,

    Well, translations were copied in my case. If it’s not supposed to be so, I probably made a mistake at some point. Wouldn’t ticking the first option in the pic linked here https://ibb.co/mTRGJ6r, instead of the second option, cause translations to be synced?

    I don’t think I did this however. But I definitely ticked the last box, and I see now in your FAQ that you advise against this.

    If you think these settings are the cause for the issue, is there a way to correct them now or should one make a new copy?

    Thank you,

    M

    Plugin Author Tim W

    (@timwhitlock)

    Those options are only intended to apply to the newly created file, but you are right – using a PO file as a template DOES copy translations. This is a bug and I will fix it in the next release.

    Thread Starter maps1990

    (@maps1990)

    Alright, if you have the chance please let me know here when it’s done so that I update and come back to mark the thread as Resolved.
    Thank you,
    M

    Plugin Author Tim W

    (@timwhitlock)

    The bug is fixed on the dev branch.

    Sync no longer copies msgstr fields from PO files by default. When the option is selected during initial Copy a new X-Loco-Fallback header is added to the file. This instructs the Sync process to keep the msgstr fields.

    Note however that Sync logic still applies in that a message merge ONLY takes place when its source text has changed. This is not a bug.

    Thread Starter maps1990

    (@maps1990)

    Right, I’ll wait for this dev version to go live, and as long as it’s corrected I’m happy. Thank you for your assistance Tim

    Thread Starter maps1990

    (@maps1990)

    Hi Tim,

    It seems the bug is back: I just synced and the translations were synced too.

    Could you please look into it?

    Thank you,

    M

    Plugin Author Tim W

    (@timwhitlock)

    The fix made in 2.4.2 was reverted in 2.4.3 after other people complained at the sudden change in functionality.

    PO files that were copied prior to 2.4.3 will still be synced as per the original behaviour. Although this behaviour was wrong, it has been left in place to maintain backward compatibility. So yes, the bug is back, but it is fixed for all newly copied files and will remain that way.

    You can ignore mentions of the X-Loco-Fallback header above. This was scrapped. A new method is in place since 2.3.3 which adds X-Loco-Template-Mode after the X-Loco-Template header. This will be set to “POT” if you select “just copy source strings”. Otherwise, as per the original behaviour the sync operation will return translations. Although it should be noted that translations are ONLY synced when a source string is added. Existing translations will never be overwritten by a sync operation of any kind.

    So if your PO file was created before version 2.4.3 then you will have to manually modify the headers in the file to benefit from the more recent fix. Specifically by adding X-Loco-Template-Mode: POT

    Thread Starter maps1990

    (@maps1990)

    Hi Tim,

    Ok so I found these 2 files
    wp-content/languages/plugins/woocommerce-fr_FR.po
    wp-content/languages/loco/plugins/woocommerce-fr_FR.po

    I go to the second one and add X-Loco-Template-Mode: POT to the header like in the linked pic?
    No need to add the quotation marks?

    Edit: I just did and it didn’t work, so I added the ” and it did work the second time. As I’m rather inexperienced regarding this can you please confirm what I did is correct, meaning: 1/ the choice of file, 2/ adding the “, and 3/ the location I chose to add this text in the file?

    Thank you,

    M

    • This reply was modified 4 years, 5 months ago by maps1990.
    • This reply was modified 4 years, 5 months ago by maps1990.
    Plugin Author Tim W

    (@timwhitlock)

    1) Your file is correct. This is the custom one.

    2,3) PO headers must be quoted, and can be in any order. All lines except the last one must have a break, so you should have:

    "X-Loco-Template: ../../languages/plugins/woocommerce-fr_FR.po\n"
    "X-Loco-Template-Mode: POT"

    Note the \n character at the end of the second last line. (you may have to scroll the code block to see it). The final header line does not need the breaj, but it probably won’t complain if you added it.

    Thread Starter maps1990

    (@maps1990)

    Tim,

    Ok thanks for these final elements, I added \n to the line before the last one like in your example.

    Best,

    M

    Thread Starter maps1990

    (@maps1990)

    Oh one last thing: my initial request was about the Woocommerce POT file, can I add the same code to my theme POT file to obtain the same result?

    (weirdly enough it doesn’t seem necessary though, the PO file is as old as the woocommerce one, but as per the test I just did, syncing only adds source strings, no translations)

    • This reply was modified 4 years, 5 months ago by maps1990.
    Plugin Author Tim W

    (@timwhitlock)

    my initial request was about the Woocommerce POT file, can I add the same code to my theme POT file

    We are not adding this to any POT file. We are adding it to a PO file to sync from another PO file instead of a POT file.

    it doesn’t seem necessary though […] syncing only adds source strings

    Correct. It is syncing from the POT file as it should without us forcing it to do otherwise. POT files don’t contain translations. This is the normal mode of operation.

    If you find this confusing, you should read the page on working with templates that I linked to earlier.

Viewing 15 replies - 1 through 15 (of 16 total)
  • The topic ‘Used “Copy” to add strings, but some were added in the original afterwards’ is closed to new replies.