Plugins texts not translated on cold refresh.
-
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.
-
@jarey have you set a default language in the plugin?
-
@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.
-
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
-
@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.
-
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:
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):
- Here the requests made on cold refresh under the same route (can only see 2 related to the plugin):
- Result:
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.
-
up! could @administrators get a little peek on it?
-
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#L40Then 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-L85If 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
.