Skip to content

Commit

Permalink
test: method call syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
levovix0 committed Nov 25, 2021
1 parent a4cf1a1 commit 87749d9
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 4 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 6 additions & 0 deletions tests/test.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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()
9 changes: 9 additions & 0 deletions translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
},
"Result is {res}": {
"": "Result is {res}"
},
"abc": {
"": "abc"
}
},
"test.nim": {
"abc": {
"": "abc",
"d": "abc"
}
}
}
9 changes: 9 additions & 0 deletions translations/ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@
},
"Result is {res}": {
"": "Результат: {res}"
},
"abc": {
"": "абв"
}
},
"test.nim": {
"abc": {
"": "абв",
"d": "абвгд"
}
}
}

0 comments on commit 87749d9

Please sign in to comment.