Plugins texts not translated on cold refresh.


  • Translator

    Hello,

    On nodebb-plugin-ignore-users i have a custom tpl that shows some data.

    This .tpl has i18n messages that show fine when navigating via ajaxify. But if i refresh the page vía F5, the strings are not translated correctly and the strings showed are in the specified fallback locale. The .tpl just make use of standard i18n support: [[file:i18n_message]] and as said before the mechanism works well in standard navigation via ajaxify.

    Could be a generalized bug? I have not noticed it since I changed from English language, to another one; so the bug could have been undetected till now since most of users use nodebb in english (personal thought).

    Thanks in advance.


  • Global Moderator

    @jarey have you set a default language in the plugin?


  • Plugin & Theme Dev

    @jarey do you use nginx to serve static assets?


  • Translator

    @PitaJ i do have en_GB as default language set on the config of the plugin.
    https://github.com/jarey/nodebb-plugin-ignore-users/blob/master/plugin.json#L56

    @pichalite I do not use ngix or apache, it reproduces on my dev environment, running only ./nodebb dev.


  • Admin

    As an aside, you are maintaining a different fork from @exodo's version? I had made a couple PRs to his repo earlier.

    I didn't notice a problem with language strings though


  • Translator

    @psychobunny no, indeed I maintain exodo's fork. My personal fork is sync with exodo's and of course includes your merged PR's. I only posted the link to mine since there is where i do development itself.


  • Translator

    Just re-tested this today and it stills reproduces on every environment.

    Some detail here (don't really know if it will help, since i'm not very familiar with the renderin engine on ajaxify and on cold refresh, but here it goes):

    • Requests made on ajaxify navigation:

    0_1471972636055_upload-a977500d-1277-4037-b8e0-985281a7e587

    The highlighted request response is the correct data, based on the language preference for the user, that in my case is "es" from Spanish:

    {"ignore":"Ignorar","unignore":"Dejar de ignorar","ignored":"Ignorados","ignore_user":"Ignorar usuario","unignore_user":"Dejar de ignorar","ignored_list":"Lista de ignorados","chat_ignored_list":"Lista de chats ignorados","ignored_no_one":"No tienes a nadie en tu lista de ignorados :)","ignored_post":"Este mensaje está oculto porque su autor está en tu lista de ignorados.","ignoring_confirmation":"Ahora estás ignorando a: %1.","unignoring_confirmation":"Ya no estás ignorando a %1.","chat.ignore":"Ignorar chats","chat.unignore":"Dejar de ignorar chats","chat.ignored":"Chats ignorados","chat.ignore_user":"Ignorar chats","chat.unignore_user":"Dejar de ignorar chats","chat.ignored_list":"Lista de chats ignorados","chat.ignored_no_one":"Tu lista de chats ignorados está vacía :)","chat.ignoring_confirmation":"Desde ahora estás ignorando los chats de %1.","chat.unignoring_confirmation":"Has dejado de ignorar los chats de %1."}

    That match the result already told (messages in spanish, expected result):

    0_1471972805095_upload-3c335018-f0e4-4acd-abb9-f315cf711d3d

    • Here the requests made on cold refresh under the same route (can only see 2 related to the plugin):

    0_1471973157063_upload-6605dea9-3087-4d56-9892-26a7362d18b0

    0_1471973250247_upload-c870856b-bd1c-4fb7-8187-84e6ab3e7fd6

    0_1471973575946_upload-b997e664-d9b0-435e-a359-8927f2df67f9

    • Result:
      0_1471973358647_upload-a371669e-18cb-4eb0-ab55-332afe38b7f4

    So, any tought on what can be causing this?

    Any insight/explanation on how the render engine works, in order to debug this issue is really appreciated.

    Thanks in advance.


  • Translator

    up! could @administrators get a little peek on it?


  • Admin

    Not sure why it isn't working but here is how it works.

    On cold load we load the current user's language setting and store it in res.locals.config https://github.com/NodeBB/NodeBB/blob/master/src/middleware/header.js#L40

    Then when you call res.render() we render the page and translate it using that setting. https://github.com/NodeBB/NodeBB/blob/master/src/middleware/render.js#L83-L85

    If for some reason res.locals.config is not set then it defaults to en_GB. You can check it out by putting some console logs there.

    When you ajaxify all the parsing and translation happens client side. https://github.com/NodeBB/NodeBB/blob/master/public/src/ajaxify.js#L175 which uses the users language value from config.


  • Translator

    @baris thank you very much! I will try to find out what is not working here! I'll let you know if there's a possible bug involved.


Log in to reply
 

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