Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add more format support like *args #220

Open
betterlch opened this issue Feb 21, 2023 · 2 comments
Open

Add more format support like *args #220

betterlch opened this issue Feb 21, 2023 · 2 comments

Comments

@betterlch
Copy link

like this:

def gettext(string, *args, **variables):
    """
        gettext(u'Hello World!')
        gettext(u'Hello %(name)s!', name='World')
        gettext(u'Hello %s!', 'World')
    """
    t = get_translations()
    if t is None:
        return string if not variables else string % variables
    s = t.ugettext(string)
    if args:
        return s % args
    else:
        return s if not variables else s % variables
@betterlch
Copy link
Author

Also,add "{}".format(*args) support in the same way, it's easy to write the code and tests.

@betterlch
Copy link
Author

betterlch commented Mar 31, 2023

like #170
maybe add a new func name fgettext to support format is better than changing func gettext

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant