Skip to content

Commit

Permalink
setup translation
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddify-com committed Jul 10, 2024
1 parent bc44299 commit bed2fab
Show file tree
Hide file tree
Showing 7 changed files with 101 additions and 17 deletions.
21 changes: 4 additions & 17 deletions hiddifypanel_bot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,9 @@
- Start a web application
- Import things from your .base module
"""

from . import utils

def main(): # pragma: no cover
"""
The main function executes on commands:
`python -m hiddifypanel_bot` and `$ hiddifypanel_bot `.
This is your program's entry point.
You can change this function to do whatever you want.
Examples:
* Run a test suite
* Run a server
* Do some other stuff
* Run a command line application (Click, Typer, ArgParse)
* List all available tasks
* Run an application (Flask, FastAPI, Django, etc.)
"""
print("This will do something")
utils.setup_translation()
import i18n
print(i18n.t("start",locale='fa'))
31 changes: 31 additions & 0 deletions hiddifypanel_bot/translations/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"start": "Welcome to the Hiddify bot.\n Use the menu below to manage.",
"unauthorized": "You do not have permission to use this bot.",
"authorized": "Unauthorized",
"error": "Your request cannot be executed",
"uuid": "Please enter your UUID:",
"adduser": "Add User",
"showuser": "Show User",
"serverinfo": "Server Information",
"backup": "Backup",
"reset": "User successfully updated",
"resettime": "User time limit updated",
"resetgb": "User data limit updated",
"addname": "Enter user name:",
"adddays": "Enter user duration:",
"addgb": "Enter user data amount:",
"help": "Help",
"helpme": "To find out your user info, you need to enter your user UUID after clicking the Show User button and wait for the information to be displayed.",
"admin": "Admin",
"addadmin": "Add",
"showadmin": "Show",
"deleteadmin": "Delete",
"backmainmenu": "Back",
"adminmenu": "Admin Menu",
"adminfail": "Error in the process",
"adminuuid": "Enter the admin UUID to delete:",
"admindeleted": "Admin successfully deleted.",
"adminnotdeleted": "Error deleting admin.",
"invaliddays": "Please enter numeric values.",
"invalidgb": "Please enter numeric values."
}
31 changes: 31 additions & 0 deletions hiddifypanel_bot/translations/fa.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"start": "به ربات هیدیفای خوش آمدید.\n از منو زیر برای مدیریت استفاده کنید ${test}",
"unauthorized": "شما مجوز استفاده از این ربات را ندارید.",
"authorized": "غیرمجاز",
"error": "درخواست شما قابل اجرا نمیباشد",
"uuid": "لطفا UUID خود را وارد نمایید :",
"adduser": "افزودن کاربر",
"showuser": "نمایش کاربر",
"serverinfo": "اطلاعات سرور",
"backup": "بکاپ",
"reset": "کاربر با موفقیت بروزرسانی شد",
"resettime": "محدودیت زمان کاربر بروزرسانی شد",
"resetgb": "محدودیت حجم کاربر بروزرسانی شد",
"addname": "نام کاربر را وارد کنید:",
"adddays": "مدت زمان کاربر را وارد کنید:",
"addgb": "مقدار حجم کاربر را وارد کنید:",
"help": "آموزش",
"helpme": "برای اطلاع از یوزر خود باید UUID یوزر خود را بعد از زدن روی کلید نمایش کاربر وارد کرده و منتظر نمایش اطلاعات باشید",
"admin": "ادمین",
"addadmin": "افزودن",
"showadmin": "نمایش",
"deleteadmin": "حذف",
"backmainmenu": "برگشت",
"adminmenu": "منو ادمین",
"adminfai": "خطا در انجام فرایند",
"adminuuid": "برای حذف UUID ادمین را وارد کنید:",
"admindeleted": "ادمین با موفقیت حذف شد.",
"adminnotdeleted": "خطایی در حذف ادمین وجود دارد.",
"invaliddays": "لطفا مقادیر با عدد وارد نمایید.",
"invalidgb": "لطفا مقادیر با عدد وارد نمایید."
}
1 change: 1 addition & 0 deletions hiddifypanel_bot/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .translation import setup_translation
8 changes: 8 additions & 0 deletions hiddifypanel_bot/utils/translation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
def setup_translation():
import i18n
import hiddifypanel_bot
i18n.load_path.append(hiddifypanel_bot.__path__[0]+'/translations')
i18n.set('file_format', 'json')
i18n.set('skip_locale_root_data',True)
i18n.set('filename_format', '{locale}.{format}')
i18n.set('placeholder_delimiter','$')
24 changes: 24 additions & 0 deletions project.inlang/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"$schema": "https://inlang.com/schema/project-settings",
"sourceLanguageTag": "en",
"languageTags": [
"en",
"pt",
"fa",
"ru",
"zh"
],
"modules": [
"https://cdn.jsdelivr.net/npm/@inlang/plugin-i18next@4/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-empty-pattern@1/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-identical-pattern@1/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-without-source@1/dist/index.js",
"https://cdn.jsdelivr.net/npm/@inlang/message-lint-rule-missing-translation@1/dist/index.js"
],
"plugin.inlang.i18next": {
"pathPattern": "./hiddifypanel_bot/translations/{languageTag}.i18n.json",
"variableReferencePattern": [
"@:"
]
}
}
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
# Add the requirements you need to this file.
# or run `make init` to create this file automatically based on the template.
# You can also run `make switch-to-poetry` to use the poetry package manager.

i18nice==0.15.5

0 comments on commit bed2fab

Please sign in to comment.