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

Python SDK to support client applications #39

Open
wants to merge 7 commits into
base: devel
Choose a base branch
from
Open

Conversation

kbairak
Copy link

@kbairak kbairak commented Dec 7, 2020

1. Initialization logic for TxNative and CDSHandler

See my blog post for the reasoning behind this.

2. Language management:

  1. TxNative has the following properties:

    • source_language_code (recommended, is set with the source_language
      kwarg to setup)
    • current_language_code (can be None, is set with the current_language
      kwarg to setup, or with set_current_language)
    • hardcoded_language_codes (can be None, is )
    • remote_languages (is populated automatically)
  2. fetch_languages will fetch the list of available languages from Transifex
    and save them in the remote_languages attribute. It will then return the
    intersection of the languages in remote_languages and
    hardcoded_language_codes if the latter has been set or all the remote
    languages otherwise. Fetching from the CDS only happens the first time.

  3. fetch_translations accepts an optional language_code argument. If set,
    it will only fetch the specified language. This will also fetch the remote
    languages lazily to check that the specified language is available.

  4. set_current_language will lazily fetch the remote languages. It will then
    lazily fetch the translations for the specified language and finally set the
    current_language_code attribute to the specified language.

  5. The language_code argument to translate is now optional. If not set, the
    current_language_code attribute will be used.

3. Event emitter

Same signatures as with the javascript SDK. You can call tx.on(EVENT_LABEL, callback) and then interesting things will happen when the current language is changed or when the translations are fetched

4. urwid SDK

Simple SDK to allow urwid applications to behave somewhat like react applications. See here for a demo

@kbairak kbairak force-pushed the client-side branch 3 times, most recently from 5147823 to 8bb72f4 Compare December 26, 2020 16:29
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

Successfully merging this pull request may close these issues.

1 participant