I want to mix several language in my document, and the output language can be chosen according to corresponding variable
I want to define this kind of command
\mulan[en,fr,ru]{arg1}{arg2}{arg3}
to return
\en{arg1}
/ \fr{arg2}
/ \ru{arg3}
The following is my basic frame, but I don't know how I can proceed.
\documentclass{article}
\usepackage{xifthen}
\newif\ifen % if English
\newif\iffr % if French
\newif\ifru % if Russia
\newif\ifcn % if Chinese
\newif\ifjp % if Japanese
\newcommand{\en}[1]{\ifen#1\fi}
\newcommand{\fr}[1]{\ifen#1\fi}
\newcommand{\ru}[1]{\ifru#1\fi}
\newcommand{\cn}[1]{\ifcn#1\fi}
\newcommand{\jp}[1]{\ifjp#1\fi}
%specify the multi languge sequence variable globaly
\def\mulanseq#1{\gdef\mymulanseq{#1}}
\newcommand{\mymulanseq}[2]{#1 #2}
\newcommand{\mulan}[2][]{
\mymulan{\ifthenelse{\isempty{#1}}{\mymulanseq}{#1}}{#2}
}
\makeatletter
\newcommand{\mymulanp}[2]
{
(#1): #2
}
\begin{document}
%choose output language
\entrue
\jptrue
\cnfalse
%define default language sequence
\mulanseq{en,jp,cn}
%explain the three sententces according default language sequence
\mulan{en-sentence}{jp-sentence}{cn-sentence}
%explain the three sententces according given language sequence
\mulan[cn,jp,en]{sentence-A}{sentence-B}{sentence-C}
%deal with variable number sentence
% only 1 sentence should be explained using the first language specification
\mulan{sentence-A}
% only 1 sentence should be explained using the first language specification
\mulan{sentence-A}{sentence-B}
\end{document}
Big thanks to Steven. Perfectly solved my question.
Can I requrie more than this?
To make the command \mulan[en,ru,fr,...]{s1}{s2}{s3}
more practical,
another seperating args \mysep
is wanted.
\mulan[en,ru,fr,...]{\mysep}{s1}{s2}{s3}
For example, concerning the following commands
\mulan[en,ru,fr]{\mysep}{s1}{s2}{s3}
will output
s1 \mysep s2 \mysep s3
(note: at the end of the s3
, there is no \mysep
)
When one of the languages is turned off, the corresponding seperator does not occur either.
\entrue
\rufalse
\frtrue
\mulan[en,ru,fr]{\mysep}{s1}{s2}{s3}
will output
s1 \mysep s3
and if the commands
\entrue
\rutrue
\frfalse
\mulan[en,ru,fr]{\mysep}{s1}{s2}{s3}
will give output
s1 \mysep s2
2015/02/10
Thanks a lot, .Steven.
I think the command you defined, \mulan
should have the following full format:
\mulan[en,jp,cn]{seperator}{Language-1}{Language-2}{Language-3}
For more convience in practical use, I want to define several simplified version for the \mulan
For example,
if the language sequence is not given, the command
\mulan
will use default language sequence given by a global variable, such as\mulanseq
\mulanseq{jp,cn,en} \mulan{+++}{MyJapanese}{MyChinese}{MyEnglish}
I want to define an alias command
\mulanp
for\mulan
, which will give some paragrah sepeprated for different language contents. Just like:\newcommand\mulanp#1{\mulan{\par}{#1}} \newcommand\mulanr#1{\mulan{\space/\space}{#1}}
So that I can input less duplicate contents in my main text.
Also, if the language sequence is not specified in \mulanp
, the default sequence will be used.
Though I am learning programing in LaTeX and I am trying to read and modify your program for dedicated uses, it is far for me to understand thoroughly your program soon.
Would you like to give me more help?
Note: for the above question 2, I have realized by the following
\def\mulanp{\expandafter\mulan{\par}}
\mulanp{MyJapanese}{MyChinese}{MyEnglish}
It looks o.k. but the first question needs your genius yet.