diff --git a/README.md b/README.md index d538a8e7..41bfa97a 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,8 @@ to read converted documents in HTML format, get support in our forum: * Create a new directory and name it to the short language code. e.g. for Germany, please name it `de_DE`. +* Add file `de_DE/_lang.md` with the full name of the language. e.g. + write `English` in `en_US/_lang.md`, `简体中文` in `zh_CN/_lang.md`. * Copy the markdown document you want to translate to new language directory, create the same sub-directories as original document. For example, to translate `en_US/howto/reset.user.password.md`, please create diff --git a/TODO.md b/TODO.md index 7c4af55a..0e97698d 100644 --- a/TODO.md +++ b/TODO.md @@ -1,3 +1 @@ -* Don't store translation files in sub-folders, use name - `-.html` instead. * How to block attachment with Amavisd diff --git a/convert.sh b/convert.sh index c956a24c..c8ff45fe 100755 --- a/convert.sh +++ b/convert.sh @@ -3,13 +3,20 @@ # Author: Zhang Huangbin # Purpose: Convert markdown articles to HTML files. -ROOTDIR="$(pwd)" +export ROOTDIR="$(pwd)" +export OUTPUT_DIR="${ROOTDIR}/html" -CONVERTER="${ROOTDIR}/tools/markdown2html.py" -CMD_CONVERT="python ${CONVERTER}" -#CMD_CONVERT=":" -CHANGED_FILES="$(hg st | grep '\.md$')" -TODAY="$(date +%Y-%m-%d)" +# A temporary directory used to copy and modify markdown files, will be removed +# after all files were converted. +export TMP_DIR="${OUTPUT_DIR}/tmp" + +export CONVERTER="${ROOTDIR}/tools/markdown2html.py" +export CMD_CONVERT="python ${CONVERTER}" +export CHANGED_FILES="$(hg st | grep '\.md$')" +export TODAY="$(date +%Y-%m-%d)" + +[ -d ${OUTPUT_DIR} ] || mkdir -p ${OUTPUT_DIR} +[ -d ${TMP_DIR} ] || mkdir -p ${TMP_DIR} strip_name_prefix() { @@ -22,19 +29,19 @@ strip_name_prefix() } # Available translations -all_languages='en_US zh_CN' +export all_languages='en_US zh_CN' # Chapter directories in specified order -all_chapter_dirs="overview \ - installation \ - mua \ - upgrade \ - migrations \ - howto \ - integrations \ - cluster \ - troubleshooting \ - faq" +export all_chapter_dirs="overview \ + installation \ + mua \ + upgrade \ + migrations \ + howto \ + integrations \ + cluster \ + troubleshooting \ + faq" # Additional directories which stores scripts or other non-Markdown files. additional_dirs="" @@ -54,28 +61,24 @@ for lang in ${all_languages}; do break fi - cd ${src_dir} - - # Directory used to store converted html files. - OUTPUT_DIR="${ROOTDIR}/html" - CSS_FILE='./css/markdown.css' - IS_SUB_FOLDER='NO' - if [ X"${lang}" != X'en_US' ]; then - OUTPUT_DIR="${ROOTDIR}/html/${lang}" - CSS_FILE='../css/markdown.css' - IS_SUB_FOLDER='YES' - fi - # Markdown file used to store index of chapters/articles. INDEX_MD="${OUTPUT_DIR}/index.md" - [ -d ${OUTPUT_DIR} ] || mkdir -p ${OUTPUT_DIR} + # Generate a index file. + has_index='NO' + if [ X"${lang}" == X'en_US' ]; then + has_index='YES' + fi + + cd ${src_dir} # Initial index file. - if [ -f ${src_dir}/_title.md ]; then - cat ${src_dir}/_title.md > ${INDEX_MD} - else - echo '' > ${INDEX_MD} + if [ X"${has_index}" == X'YES' ]; then + if [ -f ${src_dir}/_title.md ]; then + cat ${src_dir}/_title.md > ${INDEX_MD} + else + echo '' > ${INDEX_MD} + fi fi # Used for prettier printing @@ -101,17 +104,19 @@ for lang in ${all_languages}; do _title_md="${chapter_dir}/_title.md" _summary_md="${chapter_dir}/_summary.md" - if [ -f ${_title_md} ]; then - # generate index info of chapter - _chapter_title="$(cat ${_title_md})" - echo -e "### ${_chapter_title}" >> ${INDEX_MD} + if [ X"${has_index}" == X'YES' ]; then + if [ -f ${_title_md} ]; then + # generate index info of chapter + _chapter_title="$(cat ${_title_md})" + echo -e "### ${_chapter_title}" >> ${INDEX_MD} - if [ -f ${_summary_md} ]; then - echo '' >> ${INDEX_MD} - cat ${_summary_md} >> ${INDEX_MD} + if [ -f ${_summary_md} ]; then + echo '' >> ${INDEX_MD} + cat ${_summary_md} >> ${INDEX_MD} - # Insert an empty line to not mess up other formats like list. - echo '' >> ${INDEX_MD} + # Insert an empty line to not mess up other formats like list. + echo '' >> ${INDEX_MD} + fi fi fi @@ -120,9 +125,13 @@ for lang in ${all_languages}; do for article_file in ${all_chapter_articles}; do article_counter="$((article_counter+1))" article_file_basename="$(basename ${article_file})" - article_html_file="$(strip_name_prefix ${article_file_basename})" - # Replace '.md' suffix by '.html' - article_html_file="$(echo ${article_html_file/%.md/.html})" + article_html_file_orig="$(strip_name_prefix ${article_file_basename})" + # Replace '.md' suffix by '.html', and append lang code + if [ X"${lang}" == X'en_US' ]; then + article_html_file="$(echo ${article_html_file_orig/%.md/.html})" + else + article_html_file="$(echo ${article_html_file_orig/%.md/-${lang}.html})" + fi hide_article_in_index='NO' if echo "${article_file_basename}" | grep '^0-' &>/dev/null; then @@ -139,7 +148,7 @@ for lang in ${all_languages}; do # Get title in markdown file: '

title

' #_article_title="$(head -1 ${article_file} | awk -F'[<|>]' '{print $3}')" - if [ X"${hide_article_in_index}" == X'NO' ]; then + if [ X"${hide_article_in_index}" == X'NO' -a X"${has_index}" == X'YES' ]; then echo "* [${_article_title}](${article_html_file})" >> ${INDEX_MD} fi @@ -154,14 +163,55 @@ for lang in ${all_languages}; do echo -en "\n* Converting (#${article_counter}): ${lang}/${article_file}" fi + # * Detect same file in different languages + # * Modify markdown file to append a note paragraph to remind + # reader that current document has different language version. + translations='' + for tlang in ${all_languages}; do + if [ X"${tlang}" != X"${lang}" ]; then + if [ -f ${ROOTDIR}/${tlang}/${chapter_dir}/${article_file_basename} ]; then + translations="${translations} ${tlang}" + fi + fi + done + + # Has translation(s). + md_src="${article_file}" + if echo ${translations} | grep '_' &>/dev/null; then + tmp_md_orig="${TMP_DIR}/${article_file_basename}-${lang}" + tmp_md="${TMP_DIR}/${article_file_basename}" + + cp -f ${article_file} ${tmp_md_orig} + + set -x + # Generate new markdown file + # Get title line + _title_line="$(head -1 ${tmp_md_orig})" + # Remove title line + perl -pi -e 's#${_title_line}##' ${tmp_md_orig} + + echo -e "${title_line}\n\n" > ${tmp_md} + echo -e '!!! note "This tutorial is available in other languages"\n\n' >> ${tmp_md} + + for l in ${translations}; do + tmp_article_html_file="$(echo ${article_html_file_orig/%.md/-${l}.html})" + echo -e " * [$(cat ${ROOTDIR}/${l}/_lang.md)](./${tmp_article_html_file})\n" >> ${tmp_md} + done + echo -e '\n' >> ${tmp_md} + + cat ${tmp_md_orig} >> ${tmp_md} + set +x + + md_src="${tmp_md}" + rm -f ${tmp_md_orig} + fi + # Convert - ${CMD_CONVERT} ${article_file} \ + ${CMD_CONVERT} ${md_src} \ ${OUTPUT_DIR} \ output_filename="${article_html_file}" \ title="${_article_title}" \ - add_index_link='yes' \ - css="${CSS_FILE}" \ - is_sub_folder="${IS_SUB_FOLDER}" + add_index_link='yes' if [ X"$?" == X'0' ]; then echo -e ' [DONE]' @@ -177,12 +227,13 @@ for lang in ${all_languages}; do done # Append addition links at the chapter bottom on index page. - _links_md="${chapter_dir}/_links.md" - - if [ -f ${_links_md} ]; then - echo '' >> ${INDEX_MD} - cat ${_links_md} >> ${INDEX_MD} - echo '' >> ${INDEX_MD} + if [ X"${has_index}" == X'YES' ]; then + _links_md="${chapter_dir}/_links.md" + if [ -f ${_links_md} ]; then + echo '' >> ${INDEX_MD} + cat ${_links_md} >> ${INDEX_MD} + echo '' >> ${INDEX_MD} + fi fi done @@ -194,27 +245,25 @@ for lang in ${all_languages}; do echo '' echo "* ${article_counter} files total for ${lang}." - echo "* Converting ${INDEX_MD} for index page." - ${CMD_CONVERT} ${INDEX_MD} ${OUTPUT_DIR} \ - title="iRedMail Documentations" \ - css="${CSS_FILE}" \ - is_sub_folder="${IS_SUB_FOLDER}" + if [ X"${has_index}" == X'YES' ]; then + echo "* Converting ${INDEX_MD} for index page." + ${CMD_CONVERT} ${INDEX_MD} ${OUTPUT_DIR} title="iRedMail Documentations" + + # Cleanup and reset variables + rm -f ${INDEX_MD} + fi - # Cleanup and reset variables - rm -f ${INDEX_MD} article_counter=0 done +rm -rf ${TMP_DIR} &>/dev/null + # Sync newly generated HTML files to local diretories. if echo "$@" | grep -q -- '--sync-local'; then # Copy to local hg repo of http://www.iredmail.org/docs/ echo "* Syncing converted HTML files." rm -rf ../web/docs/* cp -rf ${ROOTDIR}/html/* ${ROOTDIR}/../web/docs/ - - # Copy to iredmail.com/docs/ - rm -rf /Volumes/STORAGE/Dropbox/Backup/iredmail.com/docs/* - cp -rf ${ROOTDIR}/html/* /Volumes/STORAGE/Dropbox/Backup/iredmail.com/docs/ fi # Show changed files. diff --git a/en_US/_lang.md b/en_US/_lang.md new file mode 100644 index 00000000..fb54c64e --- /dev/null +++ b/en_US/_lang.md @@ -0,0 +1 @@ +English diff --git a/en_US/faq/2-iredadmin-pro.restful.api.md b/en_US/faq/2-iredadmin-pro.restful.api.md index 3371df69..f106597b 100644 --- a/en_US/faq/2-iredadmin-pro.restful.api.md +++ b/en_US/faq/2-iredadmin-pro.restful.api.md @@ -11,8 +11,8 @@ iRedAdmin-Pro RESTful API will return message in JSON format. -* If operation succeed, it returns JSON `{'success': true}`. -* If operation failed, it returns JSON `{'success': false, 'msg': ''}`. +* If operation succeed, client will receive JSON data: `{'success': true}`. +* If operation failed, client will receive JSON data: `{'success': false, 'msg': ''}`. ## Requirements diff --git a/en_US/installation/0-install.iredmail.on.rhel.md b/en_US/installation/0-install.iredmail.on.rhel.md index b5ce7a97..f19bdb84 100644 --- a/en_US/installation/0-install.iredmail.on.rhel.md +++ b/en_US/installation/0-install.iredmail.on.rhel.md @@ -2,11 +2,6 @@ [TOC] -> This tutorial is available in other languages: -> -> * [Russian](http://www.everycloudtech.com/install.iredmail.on.rhel). Thanks to [Everycloudtech](http://www.everycloudtech.com/). -> * [简体中文](./zh_CN/install.iredmail.on.rhel.html) - ## System Requirements !!! warning diff --git a/html/zh_CN/allow.member.to.send.email.as.mail.list.html b/html/allow.member.to.send.email.as.mail.list-zh_CN.html similarity index 81% rename from html/zh_CN/allow.member.to.send.email.as.mail.list.html rename to html/allow.member.to.send.email.as.mail.list-zh_CN.html index bc51cce1..d5acd2d7 100644 --- a/html/zh_CN/allow.member.to.send.email.as.mail.list.html +++ b/html/allow.member.to.send.email.as.mail.list-zh_CN.html @@ -2,19 +2,25 @@ 允许列表成员以列表邮件地址作为发件人发送邮件 - +

允许列表成员以列表邮件地址作为发件人发送邮件

+   //  Document Index
+

This tutorial is available in other languages

+ +
+

允许列表成员以列表邮件地址作为发件人发送邮件

要允许列表成员以列表邮件地址作为发件人发送邮件,请按照以下步骤操作:

  • 在 Postfix 配置文件 /etc/postfix/main.cf 中移除参数 reject_sender_login_mismatch
  • diff --git a/html/allow.member.to.send.email.as.mail.list.html b/html/allow.member.to.send.email.as.mail.list.html index b8103aad..664bdbd4 100644 --- a/html/allow.member.to.send.email.as.mail.list.html +++ b/html/allow.member.to.send.email.as.mail.list.html @@ -14,7 +14,13 @@ />  iRedMail -   //  Document Index

    Allow member to send email as mailing list or mail alias

    +   //  Document Index
    +

    This tutorial is available in other languages

    + +
    +

    Allow member to send email as mailing list or mail alias

    To allow member of mailing list (or mail alias) account to send email as this mailing list (or mail alias), please follw steps below:

      diff --git a/html/zh_CN/allow.user.to.send.email.without.authentication.html b/html/allow.user.to.send.email.without.authentication-zh_CN.html similarity index 82% rename from html/zh_CN/allow.user.to.send.email.without.authentication.html rename to html/allow.user.to.send.email.without.authentication-zh_CN.html index c7a2f59a..2c0bc755 100644 --- a/html/zh_CN/allow.user.to.send.email.without.authentication.html +++ b/html/allow.user.to.send.email.without.authentication-zh_CN.html @@ -2,19 +2,25 @@ 允许用户无需身份验证发送邮件 - +

      允许用户无需身份验证发送邮件

      +   //  Document Index
      +

      This tutorial is available in other languages

      + +
      +

      允许用户无需身份验证发送邮件

      创建文本文件 /etc/postfix/accepted_unauth_senders,列出无需身份验证就可以 发送邮件的用户邮件地址。下面以用户 user@example.com 为例:

      user@example.com OK
      diff --git a/html/allow.user.to.send.email.without.authentication.html b/html/allow.user.to.send.email.without.authentication.html
      index 6e65833d..1becd7e4 100644
      --- a/html/allow.user.to.send.email.without.authentication.html
      +++ b/html/allow.user.to.send.email.without.authentication.html
      @@ -14,7 +14,13 @@
                    /> 
               iRedMail
           
      -      //  Document Index

      Allow user to send email without smtp authentication

      +   //  Document Index
      +

      This tutorial is available in other languages

      + +
      +

      Allow user to send email without smtp authentication

      Create a plain text file: /etc/postfix/accepted_unauth_senders, list all users' email addresses which are allowed to send email without smtp authentication. We use user email address user@example.com for example:

      diff --git a/html/zh_CN/change.mail.attachment.size.html b/html/change.mail.attachment.size-zh_CN.html similarity index 93% rename from html/zh_CN/change.mail.attachment.size.html rename to html/change.mail.attachment.size-zh_CN.html index 62cf30fd..7be2b624 100644 --- a/html/zh_CN/change.mail.attachment.size.html +++ b/html/change.mail.attachment.size-zh_CN.html @@ -2,19 +2,25 @@ 修改邮件附件大小 - +

      修改邮件附件大小

      +   //  Document Index
      +

      This tutorial is available in other languages

      + +
      +

      修改邮件附件大小

      • 修改邮件附件大小
          diff --git a/html/change.mail.attachment.size.html b/html/change.mail.attachment.size.html index 447deedd..d6440780 100644 --- a/html/change.mail.attachment.size.html +++ b/html/change.mail.attachment.size.html @@ -14,7 +14,13 @@ />  iRedMail -   //  Document Index

      Change mail attachment size

      +   //  Document Index
      +

      This tutorial is available in other languages

      + +
      +

      Change mail attachment size

      • Change mail attachment size
          diff --git a/html/zh_CN/change.server.hostname.html b/html/change.server.hostname-zh_CN.html similarity index 86% rename from html/zh_CN/change.server.hostname.html rename to html/change.server.hostname-zh_CN.html index b6171e03..2fbf5ac7 100644 --- a/html/zh_CN/change.server.hostname.html +++ b/html/change.server.hostname-zh_CN.html @@ -2,19 +2,25 @@ 修改服务器主机名 - +

          修改服务器主机名

          +   //  Document Index
      +

      This tutorial is available in other languages

      + +
      +

      修改服务器主机名

      要在安装 iRedMail 后修改服务器的主机名,请将以下文件中的旧主机名改为新主机名:

      系统配置文件