Kasianov Nikolai Alekseevich
5 days ago
31 changed files with 855 additions and 70 deletions
@ -0,0 +1,55 @@
|
||||
package i18n |
||||
|
||||
import ( |
||||
"encoding/json" |
||||
"io" |
||||
"os" |
||||
) |
||||
|
||||
type Language string |
||||
|
||||
func (l *Language) String() string { |
||||
return string(*l) |
||||
} |
||||
|
||||
const ( |
||||
Ru Language = "ru" |
||||
Eng Language = "eng" |
||||
) |
||||
|
||||
type Translations []*Translation |
||||
|
||||
func (ts *Translations) Add(translation *Translation) { |
||||
*ts = append(*ts, translation) |
||||
} |
||||
|
||||
type Translation struct { |
||||
Language Language `json:"language"` |
||||
Messages []Message `json:"messages"` |
||||
} |
||||
|
||||
type Message struct { |
||||
ID string `json:"id"` |
||||
Translation string `json:"translation"` |
||||
} |
||||
|
||||
func FromFile(filePath string) (*Translation, error) { |
||||
file, err := os.Open(filePath) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
defer file.Close() |
||||
|
||||
contents, err := io.ReadAll(file) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
var translation Translation |
||||
err = json.Unmarshal(contents, &translation) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return &translation, nil |
||||
} |
@ -0,0 +1,16 @@
|
||||
package i18n |
||||
|
||||
import ( |
||||
"path/filepath" |
||||
) |
||||
|
||||
func GetPageTranslation(pageName string, language Language, translationsDirPath string) (*Translation, error) { |
||||
translation, err := FromFile( |
||||
filepath.Join(translationsDirPath, language.String(), pageName+".json"), |
||||
) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return translation, nil |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "about info", |
||||
"message": "a dead simple and minimalistic web TODO list", |
||||
"translation": "a dead simple and minimalistic web TODO list" |
||||
}, |
||||
{ |
||||
"id": "about register", |
||||
"message": "Register", |
||||
"translation": "Register" |
||||
}, |
||||
{ |
||||
"id": "about log in", |
||||
"message": "Log In", |
||||
"translation": "Log In" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,25 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "base link main", |
||||
"message": "Main", |
||||
"translation": "Main" |
||||
}, |
||||
{ |
||||
"id": "base link about", |
||||
"message": "About", |
||||
"translation": "About" |
||||
}, |
||||
{ |
||||
"id": "base link log in", |
||||
"message": "Log in", |
||||
"translation": "Log In" |
||||
}, |
||||
{ |
||||
"id": "base link sign up", |
||||
"message": "Sign-Up", |
||||
"translation": "Sign-Up" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,135 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "category modal confirm deletion", |
||||
"message": "Confirm Deletion", |
||||
"translation": "Confirm Deletion" |
||||
}, |
||||
{ |
||||
"id": "category modal deletion confirmation", |
||||
"message": "Are you sure you want to delete this ToDo?", |
||||
"translation": "Are you sure you want to delete this ToDo?" |
||||
}, |
||||
{ |
||||
"id": "category modal delete button", |
||||
"message": "Delete", |
||||
"translation": "Delete" |
||||
}, |
||||
{ |
||||
"id": "category modal cancel button", |
||||
"message": "Cancel", |
||||
"translation": "Cancel" |
||||
}, |
||||
{ |
||||
"id": "category modal draw note", |
||||
"message": "Draw Note", |
||||
"translation": "Draw Note" |
||||
}, |
||||
{ |
||||
"id": "category modal save button", |
||||
"message": "Save", |
||||
"translation": "Save" |
||||
}, |
||||
{ |
||||
"id": "category modal todo details", |
||||
"message": "TODO Details", |
||||
"translation": "TODO Details" |
||||
}, |
||||
{ |
||||
"id": "category modal todo text", |
||||
"message": "Text:", |
||||
"translation": "Text:" |
||||
}, |
||||
{ |
||||
"id": "category modal todo created", |
||||
"message": "Created:", |
||||
"translation": "Created:" |
||||
}, |
||||
{ |
||||
"id": "category modal todo due", |
||||
"message": "Due:", |
||||
"translation": "Due:" |
||||
}, |
||||
{ |
||||
"id": "category modal todo completion", |
||||
"message": "Completion Time:", |
||||
"translation": "Completion Time:" |
||||
}, |
||||
{ |
||||
"id": "category modal close button", |
||||
"message": "Close", |
||||
"translation": "Close" |
||||
}, |
||||
{ |
||||
"id": "category modal edit button", |
||||
"message": "Edit", |
||||
"translation": "Edit" |
||||
}, |
||||
{ |
||||
"id": "category categories", |
||||
"message": "Categories", |
||||
"translation": "Categories" |
||||
}, |
||||
{ |
||||
"id": "category not removable", |
||||
"message": "Not Removable", |
||||
"translation": "Not Removable" |
||||
}, |
||||
{ |
||||
"id": "category todo text", |
||||
"message": "TODO Text", |
||||
"translation": "TODO Text" |
||||
}, |
||||
{ |
||||
"id": "category due date", |
||||
"message": "Due Date", |
||||
"translation": "Due Date" |
||||
}, |
||||
{ |
||||
"id": "category add", |
||||
"message": "Add", |
||||
"translation": "Add" |
||||
}, |
||||
{ |
||||
"id": "category show done", |
||||
"message": "Show Done", |
||||
"translation": "Show Done" |
||||
}, |
||||
{ |
||||
"id": "category image", |
||||
"message": "Image", |
||||
"translation": "Image" |
||||
}, |
||||
{ |
||||
"id": "category todo", |
||||
"message": "ToDo", |
||||
"translation": "Todo" |
||||
}, |
||||
{ |
||||
"id": "category created", |
||||
"message": "Created", |
||||
"translation": "Created" |
||||
}, |
||||
{ |
||||
"id": "category due", |
||||
"message": "Due", |
||||
"translation": "Due" |
||||
}, |
||||
{ |
||||
"id": "category completed", |
||||
"message": "Completed", |
||||
"translation": "Completed" |
||||
}, |
||||
{ |
||||
"id": "category enter todo text", |
||||
"message": "Enter ToDo Text", |
||||
"translation": "Enter ToDo Text" |
||||
}, |
||||
{ |
||||
"id": "category js button show todo", |
||||
"message": "Show To Do", |
||||
"translation": "Show To Do" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "error error big", |
||||
"message": "Error!", |
||||
"translation": "Error!" |
||||
}, |
||||
{ |
||||
"id": "error something went wrong", |
||||
"message": "Sorry! Something went wrong somewhere!", |
||||
"translation": "Sorry! Something went wrong somewhere!" |
||||
}, |
||||
{ |
||||
"id": "error try to reload", |
||||
"message": "Try to reload the faulty page or try again later", |
||||
"translation": "Try to reload the faulty page or try again later" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "index categories", |
||||
"message": "Categories", |
||||
"translation": "Categories" |
||||
}, |
||||
{ |
||||
"id": "index not removable", |
||||
"message": "Not removable", |
||||
"translation": "Not removable" |
||||
}, |
||||
{ |
||||
"id": "index jump here", |
||||
"message": "Jump here", |
||||
"translation": "Jump here" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "login main", |
||||
"message": "Log In", |
||||
"translation": "Log In" |
||||
}, |
||||
{ |
||||
"id": "login placeholder password", |
||||
"message": "Password", |
||||
"translation": "Password" |
||||
}, |
||||
{ |
||||
"id": "index jump here", |
||||
"message": "Jump here", |
||||
"translation": "Jump here" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,50 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "register main", |
||||
"message": "Register", |
||||
"translation": "Register" |
||||
}, |
||||
{ |
||||
"id": "register passwords info", |
||||
"message": "Passwords are hashed client-side, your information is protected", |
||||
"translation": "Passwords are hashed client-side, your information is protected" |
||||
}, |
||||
{ |
||||
"id": "register placeholder password", |
||||
"message": "Password", |
||||
"translation": "Password" |
||||
}, |
||||
{ |
||||
"id": "register email verification", |
||||
"message": "Email Verification", |
||||
"translation": "Email Verification" |
||||
}, |
||||
{ |
||||
"id": "register email verification info", |
||||
"message": "Enter the verification code sent to your email address", |
||||
"translation": "Enter the verification code sent to your email address" |
||||
}, |
||||
{ |
||||
"id": "register email verification code", |
||||
"message": "Verification Code", |
||||
"translation": "Verification Code" |
||||
}, |
||||
{ |
||||
"id": "register enter code", |
||||
"message": "Enter your code", |
||||
"translation": "Enter your code" |
||||
}, |
||||
{ |
||||
"id": "register verify", |
||||
"message": "Verify", |
||||
"translation": "Verify" |
||||
}, |
||||
{ |
||||
"id": "register button", |
||||
"message": "Register", |
||||
"translation": "Register" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "about info", |
||||
"message": "a dead simple and minimalistic web TODO list", |
||||
"translation": "простой и минималистичный сервис по ведению текстовых заметок" |
||||
}, |
||||
{ |
||||
"id": "about register", |
||||
"message": "Register", |
||||
"translation": "Зарегистрироваться" |
||||
}, |
||||
{ |
||||
"id": "about log in", |
||||
"message": "Log In", |
||||
"translation": "Войти" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,25 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "base link main", |
||||
"message": "Main", |
||||
"translation": "Главная" |
||||
}, |
||||
{ |
||||
"id": "base link about", |
||||
"message": "About", |
||||
"translation": "О нас" |
||||
}, |
||||
{ |
||||
"id": "base link log in", |
||||
"message": "Log in", |
||||
"translation": "Войти" |
||||
}, |
||||
{ |
||||
"id": "base link sign up", |
||||
"message": "Sign-Up", |
||||
"translation": "Зарегистрироваться" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,135 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "category modal confirm deletion", |
||||
"message": "Confirm Deletion", |
||||
"translation": "Подтвердите удаление" |
||||
}, |
||||
{ |
||||
"id": "category modal deletion confirmation", |
||||
"message": "Are you sure you want to delete this ToDo?", |
||||
"translation": "Вы действительно хотите удалить эту заметку?" |
||||
}, |
||||
{ |
||||
"id": "category modal delete button", |
||||
"message": "Delete", |
||||
"translation": "Удалить" |
||||
}, |
||||
{ |
||||
"id": "category modal cancel button", |
||||
"message": "Cancel", |
||||
"translation": "Отменить" |
||||
}, |
||||
{ |
||||
"id": "category modal draw note", |
||||
"message": "Draw Note", |
||||
"translation": "Рисование заметки" |
||||
}, |
||||
{ |
||||
"id": "category modal save button", |
||||
"message": "Save", |
||||
"translation": "Сохранить" |
||||
}, |
||||
{ |
||||
"id": "category modal todo details", |
||||
"message": "TODO Details", |
||||
"translation": "Описание заметки" |
||||
}, |
||||
{ |
||||
"id": "category modal todo text", |
||||
"message": "Text:", |
||||
"translation": "Текст:" |
||||
}, |
||||
{ |
||||
"id": "category modal todo created", |
||||
"message": "Created:", |
||||
"translation": "Создано:" |
||||
}, |
||||
{ |
||||
"id": "category modal todo due", |
||||
"message": "Due:", |
||||
"translation": "Окончание:" |
||||
}, |
||||
{ |
||||
"id": "category modal todo completion", |
||||
"message": "Completion Time:", |
||||
"translation": "Выполнено:" |
||||
}, |
||||
{ |
||||
"id": "category modal close button", |
||||
"message": "Close", |
||||
"translation": "Закрыть" |
||||
}, |
||||
{ |
||||
"id": "category modal edit button", |
||||
"message": "Edit", |
||||
"translation": "Изменить" |
||||
}, |
||||
{ |
||||
"id": "category categories", |
||||
"message": "Categories", |
||||
"translation": "Категории" |
||||
}, |
||||
{ |
||||
"id": "category not removable", |
||||
"message": "Not Removable", |
||||
"translation": "Неудаляемое" |
||||
}, |
||||
{ |
||||
"id": "category todo text", |
||||
"message": "TODO Text", |
||||
"translation": "Текст заметки" |
||||
}, |
||||
{ |
||||
"id": "category due date", |
||||
"message": "Due Date", |
||||
"translation": "Дата выполнения" |
||||
}, |
||||
{ |
||||
"id": "category add", |
||||
"message": "Add", |
||||
"translation": "Добавить" |
||||
}, |
||||
{ |
||||
"id": "category show done", |
||||
"message": "Show Done", |
||||
"translation": "Показать выполненные" |
||||
}, |
||||
{ |
||||
"id": "category image", |
||||
"message": "Image", |
||||
"translation": "Изображение" |
||||
}, |
||||
{ |
||||
"id": "category todo", |
||||
"message": "ToDo", |
||||
"translation": "Заметка" |
||||
}, |
||||
{ |
||||
"id": "category created", |
||||
"message": "Created", |
||||
"translation": "Создано" |
||||
}, |
||||
{ |
||||
"id": "category due", |
||||
"message": "Due", |
||||
"translation": "Окончание" |
||||
}, |
||||
{ |
||||
"id": "category completed", |
||||
"message": "Completed", |
||||
"translation": "Выполнено" |
||||
}, |
||||
{ |
||||
"id": "category enter todo text", |
||||
"message": "Enter ToDo Text", |
||||
"translation": "Введите текст заметки" |
||||
}, |
||||
{ |
||||
"id": "category js button show todo", |
||||
"message": "Show To Do", |
||||
"translation": "К невыполненным" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "error error big", |
||||
"message": "Error!", |
||||
"translation": "Ошибка!" |
||||
}, |
||||
{ |
||||
"id": "error something went wrong", |
||||
"message": "Sorry! Something went wrong somewhere!", |
||||
"translation": "Приносим свои извинения! Что-то пошло не так!" |
||||
}, |
||||
{ |
||||
"id": "error try to reload", |
||||
"message": "Try to reload the faulty page or try again later", |
||||
"translation": "Попробуйте перезагрузить страницу, или попробовать позже" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,20 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "index categories", |
||||
"message": "Categories", |
||||
"translation": "Категории" |
||||
}, |
||||
{ |
||||
"id": "index not removable", |
||||
"message": "Not removable", |
||||
"translation": "Неудаляемое" |
||||
}, |
||||
{ |
||||
"id": "index jump here", |
||||
"message": "Jump here", |
||||
"translation": "Перейти" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,15 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "login main", |
||||
"message": "Log In", |
||||
"translation": "Войти" |
||||
}, |
||||
{ |
||||
"id": "login placeholder password", |
||||
"message": "Password", |
||||
"translation": "Пароль" |
||||
} |
||||
] |
||||
} |
@ -0,0 +1,50 @@
|
||||
{ |
||||
"language": "ENG", |
||||
"messages": [ |
||||
{ |
||||
"id": "register main", |
||||
"message": "Register", |
||||
"translation": "Регистрация" |
||||
}, |
||||
{ |
||||
"id": "register passwords info", |
||||
"message": "Passwords are hashed client-side, your information is protected", |
||||
"translation": "Пароли хешируются на стороне клиента, Ваша информация в безопасности" |
||||
}, |
||||
{ |
||||
"id": "register placeholder password", |
||||
"message": "Password", |
||||
"translation": "Пароль" |
||||
}, |
||||
{ |
||||
"id": "register email verification", |
||||
"message": "Email Verification", |
||||
"translation": "Подтверждение почты" |
||||
}, |
||||
{ |
||||
"id": "register email verification info", |
||||
"message": "Enter the verification code sent to your email address", |
||||
"translation": "Введите код подтверждения, отправленный на вашу почту" |
||||
}, |
||||
{ |
||||
"id": "register email verification code", |
||||
"message": "Verification Code", |
||||
"translation": "Код подтверждения" |
||||
}, |
||||
{ |
||||
"id": "register enter code", |
||||
"message": "Enter your code", |
||||
"translation": "Введите ваш код" |
||||
}, |
||||
{ |
||||
"id": "register verify", |
||||
"message": "Verify", |
||||
"translation": "Подтвердить" |
||||
}, |
||||
{ |
||||
"id": "register button", |
||||
"message": "Register", |
||||
"translation": "Зарегистрироваться" |
||||
} |
||||
] |
||||
} |
Loading…
Reference in new issue