diff --git a/README.md b/README.md index e19505b..d07b1b7 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,9 @@ translations/ru.json ## specifing context ```nim -tr"it is working!" # same as "" context -tr("it is working!", "") # "оно работает!" -tr("it is working!", "code") # "он работает!" +"it is working!".tr # same as "" context +"it is working!".tr("") # "оно работает!" +"it is working!".tr("code") # "он работает!" ``` ```json @@ -73,6 +73,5 @@ echo tr"Hi, {name}" ## known issues -* `"abc".tr("d")` is not working correctly * recompilation without changing code is not updating translations * translations directory needs to be created manually diff --git a/tests/test.nim b/tests/test.nim index 03c786e..b6bf0b2 100644 --- a/tests/test.nim +++ b/tests/test.nim @@ -26,4 +26,10 @@ test "formating": let res = 88305 * 24314 / 21 check tr"Result is {res}" == "Результат: 102240370.0" +test "method call syntax": + lang = Language.ru + check "abc".tr == "абв" + check "abc".tr("") == "абв" + check "abc".tr("d") == "абвгд" + updateTranslations() diff --git a/translations/en.json b/translations/en.json index d516673..972a26e 100644 --- a/translations/en.json +++ b/translations/en.json @@ -9,6 +9,15 @@ }, "Result is {res}": { "": "Result is {res}" + }, + "abc": { + "": "abc" + } + }, + "test.nim": { + "abc": { + "": "abc", + "d": "abc" } } } \ No newline at end of file diff --git a/translations/ru.json b/translations/ru.json index 7a19617..00d7364 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -9,6 +9,15 @@ }, "Result is {res}": { "": "Результат: {res}" + }, + "abc": { + "": "абв" + } + }, + "test.nim": { + "abc": { + "": "абв", + "d": "абвгд" } } } \ No newline at end of file