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

Proposal for support of multiple languages #3

Merged
merged 2 commits into from
May 27, 2016

Conversation

CristianCantoro
Copy link
Contributor

@CristianCantoro CristianCantoro commented May 27, 2016

This pull request is the beginning of the work for addressing issue #2.

The idea is to create some submodules that deal each one with a given language (see for example in the pull request the subdirectories en and it in wikiciteparser) where the language-depended functions and/or data should be added.

In particular in this pull request the __init__.py files for the submodules en and it both contain the definition of the citation template names that are supported within the set citation_template_names. The content of __init__.py is executed when the module is imported.

The submodules should contain all the code that is language specific, then you can use dynamic import like this:

    lang_module = __import__(lang)
    if template_name in lang_module.citation_template_names:
        return template_name

where lang is a string with a specific language code (e.g. en, it)

To support new languages one just need to create another subdirectory (e.g. es, de, etc.) and implement a list of needed function. For now, you just need to define the set citation_template_names

Do you think that this design could work for this library? Do you have any comments?

I should add also some test for itwiki templates.

@wetneb
Copy link
Member

wetneb commented May 27, 2016

Excellent, thanks, happily merging!

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.

2 participants