Translation files of Events Calendar Plugin stored twice

Home Forums Additional Help Translations Translation files of Events Calendar Plugin stored twice

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #1279967
    Oliver
    Participant

    Hi,

    after working for several year with The Events Calendar I often had difficulties with the language files, especially when I updated the language files manually (with Poedit) and uploaded them to my WordPress installation.

    Today I found one reason for the headache it gave me in the past:
    the languages files (the-events-calendar-de_DE.mo / .po) of The Events Calendar Plugin are stored twice at two different locations:

    1. wp-content/languages/plugins
    2. wp-content/plugins/the-events-calendar/lang

    This this done intentionally or a bug?

    I would expect (and recommend) to store them only at one location (probably the directory /plugins/the-events-calendar/lang) to avoid any issues.

    Best regards,
    Oliver

    #1280176
    Andras
    Keymaster

    Grüss dich Oliver,

    That is an excellent question you posted there, thank you for it. I’ll try to set this straight for you to clear away the confusion and make your work easier and less frustrating in the future.

     

    wp-content/plugins/the-events-calendar/lang

    This is where our plugins contain the original language files. Whenever you update The Events Calendar, the newest translation files will be downloaded here, and thus the old ones will be overwritten. So if you made any modifications in the .po/.mo files in this folder, those modifications will be lost after an update.

     

    wp-content/languages/plugins

    This is where you can store you own language files that override the ones in the wp-content/plugins/the-events-calendar/lang folder. So if you have a .po/.mo here, then the one in the folder of the plugin itself will not be used.

     

    Thus, if you have custom translations it is recommended to keep them in wp-content/languages/plugins, because this way 1) that will be the one that is used; 2) it will not get overwritten with a plugin update.

     

    Now, what happens / what can you do when the plugin receives new strings or some strings are modified with a plugin update?

    You can update the .po/.mo files in the wp-content/languages/plugins folder from the .pot file that is in the lang folder of the plugin.

    Since you use PoEdit I guess you know how this works, but for other’s here is the process.

    Updating .po/.mo language files with PoEdit:

    1. Download the .po file to your computer and open it with PoEdit
    2. From the menu choose Catalog > Update from POT file …
    3. The new strings will be added, unused strings will be removed, modified strings will be updated
    4. Save your .po file
    5. Upload your .po and .mo file to wp-content/languages/plugins 

     

    Updating .po/.mo language files with Loco Translate

    1. Log in to your Dashboard and go to Loco Translate
    2. Click on the appropriate plugin
    3. Click on the appropriate language
    4. Click on the “Sync” button
    5. If all goes well you should see a success message: “OK: Already up to date with plugin-name.pot”

    This is it.

    For some further info on translation I recommend these readings:

    Translating The Events Calendar

    Translating the premium plugins

    Incomplete translations

     

    I hope this clarifies. Let me know if you have any more questions regarding this, I’m happy to help.

    Cheers,
    Andras

     

     

    #1280358
    Oliver
    Participant

    Dear Andras,

    thanks for the explanation. That helps for a better understanding.

    But unfortunately my experience is different from what you stated above:

    When installing a new version of the TEC plugin, the languages files are overridden/created in BOTH directories. Please have a look at the screenshots. They have a timestamp from May 5th/7th, but I definitely haven’t touch them by myself (and I just checked our test-, staging and productive system to be 100% sure – all the same result). So it looks something in the (WordPress translation) update mechanism is copying the files there…

    Best regards,
    Oliver

    #1280739
    Andras
    Keymaster

    Hmmm… thanks Oliver, that is interesting.

    Let me do some investigation on this and I’ll let you know.

    Andras

    #1280847
    Andras
    Keymaster

    I ran the following test now:

    I will be referring to these:

    • plugin folder: wp-content/plugins/the-events-calendar/lang
    • WP folder: wp-content/languages/plugins

    So the test

    • downgrade to TEC 4.4.5
    • deactivate all other plugins (to remove clutter)
    • delete all translation files from wp-content/languages/plugins
    • set the site to a different language than English (I used Hungarian)
    • add a translation to one of the strings in the plugin folder
    • check frontend
      • => translates fine
    • add a different translation to the same string in the WP folder
    • check frontend
      • => translation is taken from the WP folder
    • run update of languages at Dashboard > Updates
      • => missing language files for all my plugins are downloaded (including deactivated plugins); BUT the Hungarian TEC language file in the WP folder is untouched
    • run update of TEC 4.4.5 to 4.5.1
      • => language files in plugin folder are overwritten (with the update all plugins files are deleted and unzipped from the new package); thus the previously translated string disappears from the plugin folder
      • language files in the WP folder are not touched so my custom translation stayed in place

    So far everything seems to be working fine. Maybe I need to leave this untouched now and wait for another version update.

    It also can be that when WordPress is checking for the language updates and sees a newer file date in the repo (because strings have been removed / added / changed) – newer file date in repo vs your local – then it downloads it thinking it’s a more complete one. And so it overrides your.

    But this is just a though I would need confirmation if this is what happens.

    What can be done against this? Tough one, but I have some ideas.

    • Create a backup of the language files before updating and if it changes you can put them back / merge them somehow.
    • I believe with Loco Translate there is a third folder you can use: languages/loco/plugins/the-events-calendar-<locale>.po
      This is likely not touched by any updates so might be the best place for the language files. But for this you need the Loco Translate plugin to be active.
    • When you have a new translation, add it to the repo (WP for the free plugins or our repo for the premium plugins.)

    I’d be happy to hear your thoughts.

    Cheers,
    Andras

     

    #1281156
    Oliver
    Participant

    Hi Andras,

    thanks for your effort in testing this so detailed! I really appreciate this!

    I pick the idea about the WordPress update process:

    1. I updated the translation of the TEC plugin on the WordPress site on May 7 around 14:00 (I’m the official translator of the German translation 😉
    2. The update was available in the WordPress Dashboard around 3 hours later (pretty fast) => the timestamp of the files in the plugins directory is May 7 16:58.

    Therefore I expect that the WordPress update process is the reason for the override!

    Independently from that the question: do you know what the trigger for the WordPress website to sent out a “message” to the Dashboard, that a translation is available? Sometimes it takes hours, sometimes days or weeks?!? If we know the trigger, I can make some dummy changes to the translation and we can verify if the timestamp changes.

    Best regards,
    Oliver

    #1281505
    Andras
    Keymaster

    It looks like then that the timestamps of the WP folder files and the repo files are compared, and if the repo is newer, then an update is pulled.

    As for the trigger, unfortunately don’t know. Usually when I go to Dashboard > Updates and hit the “Check” button, then gives me if any update is available.

    Apart from this I believe there is a cron job set up in WordPress – which is triggered by a visit to the site or the Dashboard – which then checks if any updates are available. If I remember correctly that cron is set to run twice a day, but I’m not quite sure about this.

    Does this help?

    Andras

    #1281707
    Oliver
    Participant

    I follow your thoughts – maybe we are on the right path.

    I changed a little bit of the translation of TEC. Let’s wait until we get an update in the WordPress Dashboard to test it out in more detail.

    Regards,
    Oliver

    #1282196
    Andras
    Keymaster

    Right on. Keep me posted.

    A.

    #1283014
    Oliver
    Participant

    The trigger has been pulled: Today I got a message in the Dashboard that there are new translations for TEC.

    I installed it and this time the files have only been updated at
    wp-content/languages/plugins

    The files at
    wp-content/plugins/the-events-calendar/lang
    are untouched.

    It looks like your statement about the locations is right (even I don’t understand why it didn’t worked as expected during the last update).

    Best regards,
    Oliver

    #1283842
    Andras
    Keymaster

    Oliver, thanks for sharing that. I’m happy to hear it worked out now. Let’s hope it will still work like this in the future. 🙂

    I am going to close this ticket, but as you know, if you need anything else related to this topic or another please post a new one in the forum and we will be happy to help you out.

    Cheers,
    Andras

    PS: We’d be grateful if you would give us feedback on your satisfaction with support. Just click on one of the classy looking emojis below. 🙂 If you can spare a few words, that’s even better. Danke! 😉

     

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Translation files of Events Calendar Plugin stored twice’ is closed to new replies.