i18n client side / user profile links manipulation


  • Translator

    Hi,

    Is there a way Nodebb manages translations client side?

    I explain my case with further details. I'm developing a plugin that needs to add on emore option to the user profile page dropdown. I'm doing it client side, because i didn't see a way of doing it server side without modifying the theme (templates/partials/account/menu.tpl on persona theme.).

    The thing is, i can insert the new option i want, but i would like to insert the text translated in order to match forum selected language.

    Is there a way to achieve that on client side if translations are exposed on the plugin?
    I mean, if that translations are exposed by the plugin engine and can be reachable on client side too, like they are server side, with the ajaxify object ore some similar way; or am i obliged to get that translations for example by asyncronous calls to the server side of the plugin in order to just write the texts client side?

    Tried to read about it in the docs but the only info i found was server-side related.

    Thanks in advance.

    PS: Any suggestions of altering template content from plugins such as adding buttons, etc without the need of altering theme .tpls is geartly appreciated too.


  • Plugin & Theme Dev

    @jarey you can see an example of how to add links to user profile page drop down in this plugin (also uses language strings)

    https://github.com/NodeBB-Community/nodebb-plugin-user-invitations/blob/master/lib/views.js#L80


  • Translator

    @pichalite thank you very much!! :smiley:


  • Translator

    Anyone knows if theres the possibility of registering an user link in the dropdown, that will be public only? Like the case for example of the "chat link", but registered vía filter:user.profileLinks hook.

    Since in that hook theres no user info, i cannot check if the user visualizing the page is the users itself that is visualizing his/her profile or if the user its logged in, to restrict the link registration.

    I want to implement the functionality of "ignore users" showing a link that can be used to ignore, unignore from the user profile. But it has no sense to show the link "ignore/unignore user" if it is the user itself or the user visiting the profile is not logged in.

    I know it can be easilly achived by adding one more attribute to the link object and modifying the menu.tpl with minor changes to reflect this behaviour (checking the new field), and without altering the existing behaviour of the theme. If the answer to the previous question is "no", what is needed to get a pull request including this behaviour accepted? Modification in all stable themes? (persona,lavender,vanilla?).
    Or would it be more suitable a request of a new action hook for action:user:viewProfile for example? To be able to make business logic checks with the data, and altering the content sent to the page for example?

    PS: Is there any way of contributing to document the list of hooks with a short explanation of each one? For example when they're fired and wich information do they send? I think it would be a good improvement for the documentation in order to make it easy to the plugin dev to without the need to dive into the core and check each hook one by one looking for one satisfying their needs. I wouldn't mind to throw 2/3 lines explaining the hooks I found useful that i'm seeing on my little plugin experiments from a noob perspective. Ping @administrators

    Thanks again and sorry for modifying the thread question.


Log in to reply
 


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