Write/overwrite localization for plugins?



  • Can I write new localizations for 3rd party plugins? Can I overwrite existing localizations for 3rd party plugins?

    If so, how?


  • Community Rep

    In you plugin.json, add a languages string.

    "languages": "public/language"
    

    Your directory structure would look like this:

    	/public/
    		language/
    			en_GB/
    				global.json
    				something.json
    			en_US/
    			pirate/
    

    Any file that has the same name as a default one will replace the default. Any new file will create a new translation set. e.g.

    something.json

    {
    	"else": "It's something else."
    }
    

    In a template:

    <p>[[something:else]]</p>
    

    Will print "It's something else."


  • GNU/Linux

    What to do depends on details about your use-case.

    Basically you're always free to fork and edit your own copy of any plugin (as long you meet the matters of its license(s)).

    So yes, you can overwrite existing localisations. Whether it's easy depends on the plugin. As long this already features a structure like @yariplus has shown above, it's pretty easy to add additional languages or replace some translations.
    But if it written without featuring NodeBBs i18n-system, you'd have to edit the code-base directly (in this case I can recommend the docs).

    Basically if the plugin.json already contains a languages key, you're most likely having an easy time editing/enhancing those.

    And of course it's always nice to create pull-requests for the original plugin to merge your changes since more language support is most often a task for the community rather than the plugin author itself.

    @yariplus Wouldn't you need <p>[[myplugin:else]]</p>?


  • Community Rep

    @yariplus Wouldn't you need <p>else</p>?

    @frissdiegurke Exactly XD


  • GNU/Linux

    @yariplus xD such a mistype. I wanted to say <p>[ [myplugin:else]]</p>. EDIT: not a mistype, translator should ignore code-blocks within posts xD @psychobunny


  • Community Rep

    @psychobunny to the rescue. :rabbit2:

    Only one space was needed, i thought i tried everything to get it to go through lol.



  • Thanks, I do understand how i18n works for plugins. I should have asked if there is a way to do this without having to fork or modify the existing plugin. It seems like the answer is no.

    Personally, I think this is a lacking feature of NodeBB.



Looks like your connection to NodeBB was lost, please wait while we try to reconnect.