Skip to content

chris1ding1/masonite-lang

Repository files navigation

Masonite Lang

Masonite Package GitHub Workflow Status (branch) PyPI Python Version GitHub release (latest by date including pre-releases) License Code style: black

Roadmap

  • Command: sorts translation files by key.
  • Supports nested translation keys.
  • Replacing Parameters in Translation Strings.

Introduction

Package description in one line displayed e.g. in README

Features

  • Add your package main features here
  • and here

Official Masonite Documentation

New to Masonite ? Please first read the Official Documentation. Masonite strives to have extremely comprehensive documentation 😃. It would be wise to go through the tutorials there. If you find any discrepencies or anything that doesn't make sense, be sure to comment directly on the documentation to start a discussion!

Have questions or want to talk? Be sure to join the Masonite Discord Community!

Installation

pip install masonite-lang

Configuration

Add LangProvider to your project in config/providers.py:

# config/providers.py
# ...
from lang import LangProvider

# ...
PROVIDERS = [
    # ...
    # Third Party Providers
    LangProvider,
    # ...
]

Then you can publish the package resources (if needed) by doing:

python craft package:publish lang

Set your application locale in .env:

APP_LOCALE=en

defaults to 'en' if not set.

Create language files in the /locales directory:

/locales
    en.json
    es.json
    zh_CN.json

Example translation file (en.json):

{
    "welcome": "Welcome to our application"
}

Usage

python

from lang.facades import Lang

Lang.current_locale()
Lang.set_locale('en')
Lang.is_locale('en')
Lang.trans('trans')

templates

In your templates, use the __() helper to display translated text:

{{ __('not') }}

If the specified translation string does not exist, the __ function will return the translation string key.

Contributing

Please read the Contributing Documentation here.

Maintainers

License

Masonite Lang is open-sourced software licensed under the MIT license.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Sponsor this project

Packages

No packages published