V
V
v- death2015-10-28 21:32:26
go
v- death, 2015-10-28 21:32:26

How to do localization at the template level?

Hello. Now the localization of the interface is done like this
template -> ru = interface in Russian
->uk = interface in Ukrainian
->br = interface in Brazilian
Somewhere they write that each phrase must be passed to the template using an array (some write constants or variables)
Now in my head thoughts are spinning about parsing the template, processing it with regular expressions and entering the finished template into a radish. Then the template is already pushed into html/template.
The processing of regular expressions will be something like this
In the template on disk, for example, we have %%in1%%
regular expression %%in1%%, replace it with the desired phrase (taking into account localization)
Phrases for replacement will be stored like this
map[string]string {
"%%in1%%" : "welcome",
"%%in2%%" : "exit",
"{{hello}}" : "Hi"
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-10-28
@vGrabko99

https://github.com/nicksnyder/go-i18n
and no need to invent anything. And for God's sake, call everything meaningful, not in1 but welcome and not in2 but exit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question