Commit 628d84f4 authored by Romain Courteaud's avatar Romain Courteaud

romain_dev: thread reader use page language inqtead of local

parent d24f824d
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
loading_class_list = ['ui-icon-spinner', 'ui-btn-icon-left'], loading_class_list = ['ui-icon-spinner', 'ui-btn-icon-left'],
disabled_class = 'ui-disabled'; disabled_class = 'ui-disabled';
function getRelativeTimeString(current_date, date) { function getRelativeTimeString(language, current_date, date) {
var diff, var diff,
abs, abs,
second = 1000, second = 1000,
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
hour = minute * 60, hour = minute * 60,
day = hour * 24, day = hour * 24,
week = day * 7, week = day * 7,
time_format = new Intl.RelativeTimeFormat(); time_format = new Intl.RelativeTimeFormat(language);
diff = date.getFullYear() - current_date.getFullYear(); diff = date.getFullYear() - current_date.getFullYear();
if (diff !== 0) { if (diff !== 0) {
...@@ -373,6 +373,7 @@ ...@@ -373,6 +373,7 @@
.declareAcquiredMethod("getUrlForList", "getUrlForList") .declareAcquiredMethod("getUrlForList", "getUrlForList")
.declareAcquiredMethod("getUrlParameter", "getUrlParameter") .declareAcquiredMethod("getUrlParameter", "getUrlParameter")
.declareAcquiredMethod("getTranslationList", "getTranslationList") .declareAcquiredMethod("getTranslationList", "getTranslationList")
.declareAcquiredMethod('getSelectedLanguage', 'getSelectedLanguage')
////////////////////////////////////////////// //////////////////////////////////////////////
// initialize the gadget content // initialize the gadget content
...@@ -384,7 +385,10 @@ ...@@ -384,7 +385,10 @@
// Cancel previous line rendering to not conflict with the asynchronous render for now // Cancel previous line rendering to not conflict with the asynchronous render for now
gadget.fetchLineContent(true); gadget.fetchLineContent(true);
return gadget.getSelectedLanguage()
.push(function (language) {
return gadget.changeState({ return gadget.changeState({
language: language,
query_string: new URI(options.query).query(true).query || '', query_string: new URI(options.query).query(true).query || '',
begin_from: 0, begin_from: 0,
lines: options.lines || 1, lines: options.lines || 1,
...@@ -392,6 +396,7 @@ ...@@ -392,6 +396,7 @@
render_timestamp: new Date().getTime(), render_timestamp: new Date().getTime(),
allDocs_result: undefined allDocs_result: undefined
}); });
});
}) })
.onStateChange(function onStateChange(modification_dict) { .onStateChange(function onStateChange(modification_dict) {
...@@ -442,7 +447,7 @@ ...@@ -442,7 +447,7 @@
datetime: entry.value.modification_date, datetime: entry.value.modification_date,
title: entry.value.modification_date, title: entry.value.modification_date,
text: getRelativeTimeString( text: getRelativeTimeString(
now, new Date(entry.value.modification_date) gadget.state.language, now, new Date(entry.value.modification_date)
) )
}), }),
domsugar('br'), domsugar('br'),
...@@ -830,7 +835,7 @@ ...@@ -830,7 +835,7 @@
this.element.querySelectorAll("div.post_content > time").forEach( this.element.querySelectorAll("div.post_content > time").forEach(
function (element) { function (element) {
element.textContent = getRelativeTimeString( element.textContent = getRelativeTimeString(
now, new Date(element.getAttribute('datetime')) gadget.state.language, now, new Date(element.getAttribute('datetime'))
); );
} }
); );
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>989.21883.22115.61832</string> </value> <value> <string>989.22938.36309.58180</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -258,7 +258,7 @@ ...@@ -258,7 +258,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1610641779.85</float> <float>1610705058.31</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment