• Resolved Aldo

    (@ab_lu)


    Hello

    We use Radicle to build our WordPress sites.
    The theme structure is different, as the actual template files reside outside the actual theme directory.

    /public/content/themes/my-theme
    /resources

    Loco loads only the strings in the “my-theme” folder.
    I tried adding ../../../../resources/ to “Source file paths” but Loco Translate does still not pick up the strings of all files in /resources.

    Could you point me to the right direction on how to get this folder scanned by Loco Translate?
    Thanks

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

    (@timwhitlock)

    Translate does still not pick up the strings of all files in /resources

    I’m not clear on whether your adding of the source path has fixed the first problem (of files being outside the theme root). This would bring us to the next problem of no strings being extracted.

    There are three points of failure as I see it: (1) A file is not considered. (2) A file is not readable. (3) The file is scanned, but string definitions in the code are not extracted.

    Are you able to say which of these appears to be the problem?

    Thread Starter Aldo

    (@ab_lu)

    Thanks for the quick feedback.
    – The files are readable
    As for 1 and 3, are there any way to debug that? Can I log somehow what files are considered and where?
    Files are checked recursively in a folder right? Are there any specifications in the naming conventions of a file? The files all end with *.blade.php.

    • This reply was modified 1 year ago by Aldo.
    Plugin Author Tim W

    (@timwhitlock)

    I’m unfamiliar with blade templates. This may actually be the issue. Can you post an example file with at least one localised string?

    The .php extension should be enough. (From memory) I don’t think .blade.php would cause them to be missed. If you want to debug that for yourself, try logging what files are considered during this iteration.

    Thread Starter Aldo

    (@ab_lu)

    Thanks for the feedback!
    I figured it out.

    Template file was set to *.pot. After definite the correct path .../../../../resources/languages/wm-app.pot and name, the strings in de the defined folder started to appear.

    One last remaining issue.
    The translations are now stored in the themes folder /public/content/themes/my-theme
    Is there a way to override this, so they get also stored where the template file resides in .../../../../resources/language?

    Plugin Author Tim W

    (@timwhitlock)

    The translations are now stored in the themes folder …. Is there a way to override this, so they get also stored where the template file resides … ?

    The “author” location for translation files observes the “Domain Path” setting. You can override this in the Advanced tab.

    Thread Starter Aldo

    (@ab_lu)

    Fantastic. All solved. Thanks a lot.

    One last quest – maybe you can just join the to the docs.
    Is it possible to add also translations for a specific plugin to the same bundle? I’ve seen there is an option to “Add set”, but I’m not sure if it is intended for that?

    Plugin Author Tim W

    (@timwhitlock)

    Strictly speaking it goes against WordPress convention for a plugin to manage more than one text domain, or for one plugin to manage multiple text domains. But from Loco Translate’s perspective, these can both be achieved.

    1. Adding a set will mean you get multiple pairs of PO/MO translation files, whether in the same text domain or not. WordPress Core does this for the “default” text domain, as mentioned here.
    2. Adding extra source paths outside a plugin’s root allows for strings to be extracted from another plugin into the current one. This would be done if you wanted to configure a “master” plugin that’s responsible for translations across a suite of related plugins.

    Mix and match these approaches depending on your exact use case.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Setup source folder for strings’ is closed to new replies.