From 86de16dd27c67732a0e163c46c23314fcddfce5f Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Sat, 3 Aug 2024 18:59:02 +0200 Subject: feat(templates/latex/academia): Support changing the language --- .../latex/academia/%INIT_APPLICATION_NAME.tex | 2 +- templates/latex/academia/headers/preamble.tex | 9 ++++--- templates/latex/academia/init.local | 28 ++++++++++++++++++++++ templates/latex/academia/lpm.toml | 5 ++-- 4 files changed, 35 insertions(+), 9 deletions(-) create mode 100755 templates/latex/academia/init.local (limited to 'templates/latex') diff --git a/templates/latex/academia/%INIT_APPLICATION_NAME.tex b/templates/latex/academia/%INIT_APPLICATION_NAME.tex index e7934fe..5484bc6 100644 --- a/templates/latex/academia/%INIT_APPLICATION_NAME.tex +++ b/templates/latex/academia/%INIT_APPLICATION_NAME.tex @@ -1,4 +1,4 @@ -% LTeX: language=en-GB +% LTeX: language=%INIT_LANGUAGE %\documentclass[a4paper, 12pt, nosolutions]{report} % \documentclass[a4paper, 12pt, onecolumn]{report} \documentclass[a4paper, 12pt, twocolumn]{scrartcl} diff --git a/templates/latex/academia/headers/preamble.tex b/templates/latex/academia/headers/preamble.tex index bc8aa8a..d87943d 100644 --- a/templates/latex/academia/headers/preamble.tex +++ b/templates/latex/academia/headers/preamble.tex @@ -9,8 +9,7 @@ % \usepackage{textcomp} % support for yen and so on, not needed since latex2e(2020) % references -\usepackage[british]{babel} % For English language support, with reformed orthography! -% \usepackage[brithish]{babel} % For English language support, with reformed orthography! +\usepackage[%INIT_BABLE_LANGUAGE]{babel} % For English language support, with reformed orthography! \usepackage{csquotes} % required by biblatex % \usepackage{biber} % required by biblatex @@ -35,7 +34,7 @@ % \bibliography{res/reference} % Set the location of the references % dates, time -\usepackage[de-DE, showdow]{datetime2} % make handling dates easier +\usepackage[%INIT_DATE_TIME_LANGUAGE, showdow]{datetime2} % make handling dates easier % index % \usepackage{index} % Helps to create an index TODO compare with other such packages @@ -49,7 +48,7 @@ \usepackage{mathrsfs} % support for the RSFS fonts (through \mathscr command) \usepackage{cancel} % allows to cancel a part in math mode, for example to shorten a term \usepackage{bm} % bold mode in math, but better than \boldsymbol command from ams. \bm -\usepackage[locale = DE]{siunitx} % For easy unit representation +\usepackage[locale = %INIT_SIUNITX_LANGUAGE]{siunitx} % For easy unit representation \sisetup{per-mode = fraction} \usepackage[version=4]{mhchem} % for \ce command @@ -89,7 +88,7 @@ % links % \usepackage[hidelinks]{hyperref} % Links in the pdf \usepackage[nospace]{varioref} -\usepackage[pdflang=de-DE]{hyperref} +\usepackage[pdflang=%INIT_DATE_TIME_LANGUAGE]{hyperref} % \hypersetup{ % colorlinks, % linkcolor={black}, diff --git a/templates/latex/academia/init.local b/templates/latex/academia/init.local new file mode 100755 index 0000000..ae57756 --- /dev/null +++ b/templates/latex/academia/init.local @@ -0,0 +1,28 @@ +#!/usr/bin/env sh + +prompt LANGUAGE "The language to use in the latex documents" "en_GB" + +bable_language="" +case "$LANGUAGE" in +"en_GB") + bable_language="british" + ;; +en_*) + bable_language="english" + ;; +de_DE | de_*) + bable_language="ngerman" + ;; + +*) + echo "'$LANGUAGE' is not yet recognized by the init.local script! Please open an issue." 1>&2 + echo "set 'BABLE_LANGUAGE' to 'NOT_YET_RECOGNIZED_PLEASE_REPLACE' to help you find instances of the variable use." 1>&2 + bable_language="NOT_YET_RECOGNIZED_PLEASE_REPLACE" + ;; +esac + +prompt BABLE_LANGUAGE "The language to use for the bable package" "$bable_language" "dont_ask" +prompt DATE_TIME_LANGUAGE "The language to use for the datetime2 package" "$(echo "$LANGUAGE" | sed 's/_/-/g')" "dont_ask" +prompt SIUNITX_LANGUAGE "The language to use for the siunitx package" "$(echo "$LANGUAGE" | sed 's/\(\w\w\).*/\U\1/')" "dont_ask" + +# vim: ft=sh diff --git a/templates/latex/academia/lpm.toml b/templates/latex/academia/lpm.toml index 0925886..d72f80f 100644 --- a/templates/latex/academia/lpm.toml +++ b/templates/latex/academia/lpm.toml @@ -3,15 +3,14 @@ main_file = "%INIT_APPLICATION_NAME.tex" [templates] section = ''' %! TEX root = ../../../%INIT_APPLICATION_NAME.tex -% LTeX: language=en-GB +% LTeX: language=%INIT_LANGUAGE \section{REPLACMENT_SECTION_TITLE} % DATE -This is some text ''' chapter = ''' %! TEX root = ../../%INIT_APPLICATION_NAME.tex -% LTeX: language=en-GB +% LTeX: language=%INIT_LANGUAGE \chapter{REPLACEMENT_CHAPTER} ''' -- cgit 1.4.1