cgnieder / substances

a chemical database
1 stars 1 forks source link

Multi Language Support #2

Open cgnieder opened 8 years ago

cgnieder commented 8 years ago

Original report by Christian KNITTL-FRANK (Bitbucket: lcnittl, GitHub: lcnittl).


It would be very nice, if there was a multi language support, with specific Name/Alt/Sort/Altsort fields for different languages in only one database file. Maybe this could be coupled with the langugae of f.e. babel. This would be most useful for the indexing feature, as it could read out the different names, depending on the language setting. Also the standard \chem{} command could automatically read out the name for the set language.

It might look like this in the database:

#!latex

\DeclareSubstance{decane}{
    lang        = {english}{
        name        = {Decane},
        sort        = {Decane},
        alt         = {\normal-Decane},
        altsort     = {n-Decane},
    },
    lang        = {german}{
        name        = {Decan},
        sort        = {Decan},
        alt         = {\normal-Decan},
        altsort     = {n-Decan},
    },
    formula     = {C10H22},
    structure   = {-[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30]},
    CAS         = {124-18-5},
    PubChem     = {15600},
    pictograms  = {flame,health},
    H           = {226,304},
    P           = {210,260,262,301+310,331},
    mass        = {142.29},
    density     = {0.73},
    mp          = {-29.7},
    bp          = {174},
    phase       = {liquid}
}

I'm sorry - I'm not sure if something like this is possible (And if this is the right place for such proposals)

cgnieder commented 8 years ago

Original comment by Clemens Niederberger (Bitbucket: cgnieder, GitHub: cgnieder).


How about something like this:

#!latex

\documentclass[12pt]{article}
\usepackage[english,ngerman]{babel}
\usepackage{substances,translations}

\DeclareTranslationFallback{decane}{Decane}
\DeclareTranslation{German}{decane}{Decan}

\DeclareSubstance{decane}{
    name        = {\GetTranslation{decane}},
    sort        = {\GetTranslation{decane}},
    alt         = {\normal-\GetTranslation{decane}},
    altsort     = {n-\GetTranslation{decane}},
    formula     = {C10H22},
    structure   = {-[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30]-[:-30]-[:30]},
    CAS         = {124-18-5},
    PubChem     = {15600},
    pictograms  = {flame,health},
    H           = {226,304},
    P           = {210,260,262,301+310,331},
    mass        = {142.29},
    density     = {0.73},
    mp          = {-29.7},
    bp          = {174},
    phase       = {liquid}
}

\begin{document}

\chem{decane}

\selectlanguage{english}

\chem{decane}

\end{document}
cgnieder commented 8 years ago

Original comment by Christian KNITTL-FRANK (Bitbucket: lcnittl, GitHub: lcnittl).


I could not think of this, but yes, this is for real a possible way. Thank you