Skip to content

Commit

Permalink
trim key used for i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
zbryikt committed Jan 23, 2021
1 parent b48a3a6 commit a7f32f5
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions bin/lib/build/pug.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions lib/build/pug.ls
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ pug-extapi = do
main = do
opt: (opt = {}) ->
if opt.i18n =>
pug-extapi.i18n = -> opt.i18n.t(it)
pug-extapi.i18n = -> opt.i18n.t((it or '').trim!)
pug-extapi.intlbase = (p = "") -> if opt.i18n.language => path.join("/intl",opt.i18n.language,p) else p
pug-extapi.{}filters.i18n = (t, o) -> opt.i18n.t(t)
pug-extapi.{}filters.i18n = (t, o) -> opt.i18n.t((t or '').trim!)
lc.i18n = opt.i18n
map: (list) ->
list
Expand Down
1 change: 1 addition & 0 deletions src/pug/index.pug
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ html
div: :i18n
i18n key filter
div= i18n("i18n key")
div: :i18n i18n key
div= i18n("alternative:namespace-test")
div= intlbase("/")
2 changes: 1 addition & 1 deletion static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
div.textContent = "livescript filter test";</script><script type="application/json">{
"output": "lson test ok"
}
</script><div>i18n 翻譯測試 ( 編譯時期, pug filter )</div><div>i18n 翻譯測試 ( 執行時期, pug function )</div><div>命名域測試成功.</div><div>/intl/zh-TW/</div></body></html>
</script><div>i18n 翻譯測試 ( 編譯時期, pug filter )</div><div>i18n 翻譯測試 ( 執行時期, pug function )</div><div>i18n 翻譯測試 ( 執行時期, pug function )</div><div>命名域測試成功.</div><div>/intl/zh-TW/</div></body></html>
2 changes: 1 addition & 1 deletion static/intl/en/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
div.textContent = "livescript filter test";</script><script type="application/json">{
"output": "lson test ok"
}
</script><div>i18n translation test ( compile time filter )</div><div>i18n translation test ( runtime function )</div><div>namespace test ok.</div><div>/intl/en/</div></body></html>
</script><div>i18n translation test ( compile time filter )</div><div>i18n translation test ( runtime function )</div><div>i18n translation test ( runtime function )</div><div>namespace test ok.</div><div>/intl/en/</div></body></html>
2 changes: 1 addition & 1 deletion static/intl/zh-TW/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@
div.textContent = "livescript filter test";</script><script type="application/json">{
"output": "lson test ok"
}
</script><div>i18n 翻譯測試 ( 編譯時期, pug filter )</div><div>i18n 翻譯測試 ( 執行時期, pug function )</div><div>命名域測試成功.</div><div>/intl/zh-TW/</div></body></html>
</script><div>i18n 翻譯測試 ( 編譯時期, pug filter )</div><div>i18n 翻譯測試 ( 執行時期, pug function )</div><div>i18n 翻譯測試 ( 執行時期, pug function )</div><div>命名域測試成功.</div><div>/intl/zh-TW/</div></body></html>

0 comments on commit a7f32f5

Please sign in to comment.