jowilf / starlette-admin

Fast, beautiful and extensible administrative interface framework for Starlette & FastApi applications
https://jowilf.github.io/starlette-admin/
MIT License
565 stars 59 forks source link

Custom i18n files #561

Closed Mkadir closed 1 month ago

Mkadir commented 1 month ago

I'm trying to add own lang to dashboard supported_locales but i cant. How can I do that, my language is not in SUPPORTED_LOCALES.

I have created messages.po and compiled messages.mo files that files in same dir with main.py

from fastapi import FastAPI
from starlette_admin.contrib.sqla import Admin
from database.models import Base, Users
from starlette.middleware import Middleware
from starlette.middleware.sessions import SessionMiddleware
from views.auth import UsernameAndPasswordProvider
from data.config import SECRET_KEY
from loader import engine

app = FastAPI(
    title="Admin Api",
    description="bot",
    version="0.0.1",
    debug=False
)

admin = Admin(
    engine,
    base_url='/admin',
    title="Dashboard",
    middlewares=[Middleware(SessionMiddleware, secret_key=SECRET_KEY),
                 ],
    auth_provider=UsernameAndPasswordProvider(),
)

admin.mount_to(app)

How can i add custom to this, translations/uz/LC_MESSAGES/messages.po and messages.mo files generated and translated to own.

I'm sorry to labeling with bug flag, so I can't find detailed information about that, maybe i don't know exactly working with babel. I hope someone can help with that here :100: thanks

jowilf commented 1 month ago

Please follow this guide to add a new locale -> https://github.com/jowilf/starlette-admin/blob/main/CONTRIBUTING.md#adding-support-for-a-new-locale

Mkadir commented 1 month ago

https://github.com/jowilf/starlette-admin/blob/main/CONTRIBUTING.md#step-2-translate-messages in here, that means I need translate generated locales from venv inside ? For now, I just want to understand using, not contributing)

jowilf commented 1 month ago

The only way you can add a new locale right now is by contributing