Skip to content

Commit cd88990

Browse files
committed
update Readme a little
1 parent 74c373f commit cd88990

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Features
99
- **Dynamic Language Support**: Add new languages by parsing PO files.
1010
- **Template Integration**: Works with Go HTML templates, extracting translation keys directly from them.
1111
- **Pluralization Support**: Handles singular and plural forms for languages with complex plural rules.
12+
- **Contextual Translations**: Supports context-based translations for more accurate localization.
1213
- **Prefix Handling**: Customizable prefix handling in translation keys, allowing for organized and readable translation files.
1314
- **Missing Translation Detection**: Scans for and logs missing translations, simplifying the translation management process.
1415

@@ -47,6 +48,7 @@ func main() {
4748
}
4849

4950
// add template functions
51+
// this will add the tl, tn, ctl and ctn functions to the template
5052
var yourTemplateFunctions = make(template.FuncMap)
5153
for k, v := range tr.FuncMap() {
5254
yourTemplateFunctions[k] = v
@@ -55,14 +57,14 @@ func main() {
5557
5658
Using the Translator in Templates
5759
--
58-
Use tl for translating singular texts and tn for plural forms.
60+
Use tl and ctl for translating singular texts and tn and ctn for plural forms.
5961
6062
```html
6163
<!-- Singular -->
6264
<p>{{ tl "Hello, World!" }}</p>
6365

6466
<!-- Plural -->
65-
<p>{{ tn "You have one message." "You have multiple messages." 5 }}</p>
67+
<p>{{ tn "You have one message." "You have %d messages." 5, 5 }}</p>
6668
```
6769
Adding a New Language
6870
--
@@ -101,7 +103,7 @@ translatedText := tr.Tl(localizer, "prefix__.your_translation_key") // output yo
101103
TODO
102104
--
103105
- add caching functionality of the loaded translated keys.
104-
- add unit tests
106+
- add more unit tests
105107
- live reload translations when the file changes
106108
- fallback language
107109

0 commit comments

Comments
 (0)