Skip to content

Commit 86cc766

Browse files
committed
set bg-color to user-agent language's column
- add colgroup and thead - languages map from /index.html - set background-color to User-Agent language's column
1 parent 70814f6 commit 86cc766

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

_plugins/translation_status.rb

+10
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,20 @@ module TranslationStatus
2424
</p>
2525
2626
<table>
27+
<colgroup>
28+
<col>
29+
<% LANGS.each do |lang| -%>
30+
<col class="<%= lang %>">
31+
<% end -%>
32+
</colgroup>
33+
<thead>
2734
<%= table_header %>
35+
</thead>
36+
<tbody>
2837
<% posts.each do |post| -%>
2938
<%= table_row(post) %>
3039
<% end -%>
40+
</tbody>
3141
</table>
3242
EOF
3343

admin/translation-status/index.html

+27
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,32 @@ <h1>News Post Translation Status</h1>
3636

3737
{% translation_status %}
3838

39+
<script type="text/javascript">
40+
var languages = {
41+
"bg": "bg",
42+
"de": "de",
43+
"es": "es",
44+
"fr": "fr",
45+
"id": "id",
46+
"it": "it",
47+
"ja": "ja",
48+
"ko": "ko",
49+
"pl": "pl",
50+
"pt": "pt",
51+
"ru": "ru",
52+
"tr": "tr",
53+
"vi": "vi",
54+
"zh-CN": "zh_cn",
55+
"zh-TW": "zh_tw"
56+
};
57+
58+
var code = window.navigator.language || window.navigator.userLanguage || "en";
59+
if (code.substr(0,2) !== "zh") { code = code.substr(0,2); }
60+
61+
var language = languages[code];
62+
if (language) {
63+
document.write('<style type="text/css">.'+language+'{background-color:lightgray}</style>');
64+
}
65+
</script>
3966
</body>
4067
</html>

0 commit comments

Comments
 (0)