• Resolved danid88

    (@danid88)


    Right now I have a fully custom theme that is translatable, also two custom plugins that also have strings that are translatable.
    I’ve been using loco translate for them.

    Right now the .pot and .po and .mo files are located in wp-content/themes/mytheme/languages for the theme and wp-content/plugins/myplugin for the plugins.

    It would be better if all these files could be in wp-content/uploads/translations.

    Is that possible, and how should I make those changes? First copy the files there, and then for each plugin and theme in loco in advanced configuration change the template file to something like ../../../uploads/translations/mytheme.pot?

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

    (@timwhitlock)

    I don’t recommend using non-standard file locations, but if that’s what you prefer then it is possible using the Advanced configuration tab as you assumed.

    However, I think the path to your directory should be “../../uploads/translations”. Configured paths must be relative to the bundle root.

    You will have to manually move any existing files.

    Thread Starter danid88

    (@danid88)

    You were right about the path with just two back steps.

    I was able to relocate the pot file with no problem, but the po and mo files are still being loaded from themes/mytheme/languages.

    I tried deleting the language file and creating a new one but the only options are in the theme folder or in wp-content/languages.

    So another approach: Is it possible to have all the files for all the plugins and themes inside the wp-content/languages folder?

    Edit: so what I did is created the new pot file in the languages/themes folder, created there the mo and po files, and then copied over the old mo and po files with the translations in them, synced and it looks all right so far. Is this in any way a ‘legal move’?

    • This reply was modified 6 years, 10 months ago by danid88.
    Plugin Author Tim W

    (@timwhitlock)

    I was able to relocate the pot file with no problem, but the po and mo files are still being loaded from themes/mytheme/languages.

    That’s because WordPress does nothing with your POT file. It’s just for Loco Translate (or whatever other editor you might be using).

    The runtime loading of MO files is handled by the code that calls load_plugin_textdomain and load_theme_textdomain respectively. If you want your own translations in a non-standard location then change your code to look for them there.

    Is it possible to have all the files for all the plugins and themes inside the wp-content/languages folder?

    For PO/MO files, yes. This is a standard WordPress location. No custom configuration required and no need to pass a custom path to the load_plugin_textdomain and load_theme_textdomain functions.

    so what I did is created the new pot file in the languages/themes folder, created there the mo and po files, and then copied over the old mo and po files with the translations in them

    I suggest you move your files. Copying files will result in confusing duplicates.

    Is this in any way a ‘legal move’?

    It is normal to have your POT file inside the theme folder. That file is part of the theme, so I don’t see any reason not to have it there. But, you can put it wherever you like as long as you tell Loco Translate where it is.

    It is perfectly “legal” to save your translations under the wp-content/languages folder, although as you’re the author I see no reason not to keep them with the POT file. Normally the wp-content/languages folder is for user defined translations to use instead of the author’s provided ones.

    Thread Starter danid88

    (@danid88)

    This clarifies a lot of things.

    First it does make sense to keep the pot file in the theme folder.

    As for the po/mo files, for me it would be better to store them in the wp-content/languages folder because of some automated processes on server side that could potentially overwrite some changes made in the meantime – but this way I could separate the code and content better.

    Thanks for your time, and the long answer!

    • This reply was modified 6 years, 10 months ago by danid88.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Move template files from theme/languages and plugin directories to uploads’ is closed to new replies.