fletcher / MultiMarkdown-6

Lightweight markup processor to produce HTML, LaTeX, and more.

Home Page:https://fletcher.github.io/MultiMarkdown-6/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MMD localization

fletcher opened this issue · comments

For the most part, the language used in MultiMarkdown documents don't matter. Whatever language you write in is the same text used in the output document.

An exception to this, however, is that there are a few phrases used in the HTML source, such as:

return to body
see footnote
see citation
see glossary

MMD-6 includes the i18n.h file to allow automatic translation of these phrases to other languages, without a performance hit.

The default language is English. Support is built in for German (missing 1 translation). Template strings are in place for Spanish.

Additional languages can be added easily.

  1. kNumberOfLanguages needs to be incremented.
  2. lc_lookup() needs to be modified -- a new language should be added to that function following the template for English/Spanish/German. The order is CRUCIALLY IMPORTANT.
  3. lc_languages() needs to be updated. The language added must be at the end of the list (in other words, the order must match that of lc_lookup(). The two letter code should be the official one for the new language.
  4. i18n_language_from_string() needs to be updated for the new language as well, using the lower case two letter code. Again, follow the template for German and Spanish.

Adding a new string is a bit more complicated, and should not generally need to be done. The TranslateTest() function is useful when doing so, however.

If you want to add/improve the translation functionality, please submit a pull request with the proposed changes. (Please use the develop branch for pull requests so I can properly merge and test.)

Thanks!!

The missing german translation for see glossary is siehe Glossar. Personally I'd prefer if all of the german translations would start with a capital letter like in Siehe Glossar. You never "start a sentence" with a lowercase letter in German and these hints could be seen as a sentence. But other users may have a different view on that.

Thanks. You don't start sentences in English with lower case letters, either, but we're probably more relaxed about whether something is a sentence or not. :)

I changed the German translations to start with uppercase letters for you though...

Thanks! I saw that siehe Zitat still starts with a lowercase s ;-)

Although it seems to be fairly easy to add translations for additional languages this is only possible for users with software development skills. One solution which would add a lot of flexibility to MMD is the use of metadata in the document to provide translations for these strings. It could look like this:

mmd-hint-body:           Zum Haupttext
mmd-hint-footnote:       Siehe Fußnote
mmd-hint-citation:       Siehe Zitat
mmd-hint-glossary:       Siehe Glossar

If one (or all) of the keys above is missing the default value form i18n.h could be used. If a key is present but has no value the hint in the generated output could just be ignored.

Together with the lang-attribute this could go even further:

lang:                       fr
mmd-hint-fr-body:           Retour au texte principal
mmd-hint-fr-footnote:       Voir note de bas de page
mmd-hint-fr-citation:       Voir citation
mmd-hint-fr-glossary:       Voir glossaire
mmd-hint-de-body:           Zum Haupttext
mmd-hint-de-footnote:       Siehe Fußnote
mmd-hint-de-citation:       Siehe Zitat
mmd-hint-de-glossary:       Siehe Glossar

In the example above MMD would use the mmd-hint-fr-* metadata entries to generate the translations. But maybe this is already a bit out of scope since it could also be achieved with a transclusion in the metadata area.

German is fixed. Thanks! I added the French as well.

It actually doesn't take much in the way of software development skills to copy and paste a few lines in the code, but either way I'm happy to update when people send translations to me.

As per the other discussion, I think a complex metadata system is the wrong way to go. In this case, it would require a different system that would have a more negative impact on performance as well.