模板:Multitrans
This template is used to reduce Lua memory usage and running time on pages with large translation tables such as water, black, star, etc. It works by replacing a lot separate Lua module invocations, one per {{t}}
or {{t+}}
call, with a single module invocation that handles a whole batch of translations at once. It has one parameter, |data=
, which should contain the entire text of one or more translation tables; it is recommended to surround a whole set of translation tables with a call to {{multitrans|data=<...>}}
.
NOTE: Put the call to {{multitrans}}
after the call to {{trans-top}}
; otherwise, the translation-adding gadget won't work right.
使用范例如下:
{{trans-top|absorbing all light}} {{multitrans|data= * Abkhaz: {{tt|ab|аиқәаҵәа}} * Acehnese: {{tt|ace|itam}} * Afrikaans: {{tt+|af|swart}} * Albanian: {{tt+|sq|zi}} * Amharic: {{tt|am|ጥቁር}} * Arabic: {{tt+|ar|أَسْوَد|m}}, {{tt|ar|سَوْدَاء|f}}, {{tt|ar|سُود|p}} *: Moroccan Arabic: {{tt|ary|كحل|tr=kḥal}} * Armenian: {{tt|hy|սև}} * Aromanian: {{tt|rup|negru}}, {{tt+|rup|laiu}} * Asháninka: {{tt|cni|cheenkari}}, {{tt|cni|kisaari}} * Assamese: {{tt|as|ক’লা}}, {{tt|as|কুলা}} {{qualifier|Central}} * Asturian: {{tt|ast|ñegru}}, {{tt|ast|negru}}, {{tt|ast|prietu}} * Atikamekw: {{tt|atj|makatewaw}} * Avar: {{tt|av|чӏегӏера}} * Aymara: {{tt|ay|ch’iyara}} * Azerbaijani: {{tt+|az|qara}} [etc.] {{trans-bottom}} {{trans-top|without light}} * Bulgarian: {{tt+|bg|тъмен}} * Catalan: {{tt+|ca|fosc}} * Dutch: {{tt+|nl|donker}} * Esperanto: {{tt+|eo|malhela}} * Estonian: {{tt+|et|pime}} * Finnish: {{tt+|fi|pimeä}} * Georgian: {{tt|ka|ბნელი}}, {{tt|ka|მუქი}}, {{tt|ka|ბუნდოვანი}} * Greek: {{tt+|el|σκοτεινός|m}}, {{tt+|el|ερεβώδης|m}} [etc.] }}<!-- close {{multitrans}} --> {{trans-bottom}}
Inside of the template, add a t
to the beginning of translation templates:
The {{tt}}
and {{tt+}}
templates are pass-throughs, so that e.g. {{tt|ary|كحل|tr=kḥal}}
generates the literal text ⦃⦃t¦ary¦كحل¦tr=kḥal⦄⦄
, with braces replaced by brace-like Unicode chars and the pipe symbol replaced by a pipe-symbol-like Unicode char. These special chars are parsed by the Lua code and call the same code that underlyingly implements {{t}}
and {{t+}}
, but because this all happens inside a single module invocation instead of a lot of separate module invocations, it's much faster and more memory-efficient.
If you are still having memory issues, try using {{multitrans|load=all|data=<...>}}
. This loads all the language data into memory at once rather than loading it as needed. From experience, this almost always increases rather than reduces memory usage, but in exceptional cases it might result in the opposite.