Difference between revisions of "Translation Macros"

From Beerplop
Line 84: Line 84:
 
|-
 
|-
 
|__NFW[1000]
 
|__NFW[1000]
|1.000
+
|one thousand, zero
 
|-
 
|-
 
|__NFW[1e20]
 
|__NFW[1e20]
|100,000 Quintillion
+
|one hundred quintillion, zero quadrillion, zero trillion, zero billion, zero million, zero thousand, zero
 
|}
 
|}
  

Revision as of 03:05, 15 September 2020

Variables

Translations may contain variables which are filled from the application.

__AMOUNT__ queued builds

Examples
Macro Output
__AMOUNT__ queued builds 6 queued builds
Research project __PROJECT__ finished after __DURATION__ Research project Clonedike finished after 5 days and 8 hours

__NF[$number]

NumberFormat

$number contains a number (may be calculated). The number will be formatted regarding the clients locale opening Beerplop. The formatting will contain a single decimal place. Large numbers will be formatted with labels and three decimal places. Even larger numbers will be formatted in the scientific notation.

Examples
Macro Output
__NF[1000] 1.000,0
__NF[0.5] 0,5
__NF[1e20] 100,000 Quintillion

__NFI[$number]

NumberFormatInteger

$number contains a number (may be calculated). The number will be formatted regarding the clients locale opening Beerplop. The formatting will contain no decimal place. Large numbers will be formatted with labels and three decimal places. Even larger numbers will be formatted in the scientific notation.

Examples
Macro Output
__NFI[1000] 1.000
__NFI[0.5] 1
__NFI[1e20] 100,000 Quintillion

__NFR[$number]

NumberFormatRomanize

$number contains a number (may be calculated). The number will be formatted romanized.

Examples
Macro Output
__NFR[9] IX
__NFR[987] CMLXXXVII
__NFR[3999] MMMCMXCIX

__NFW[$number]

NumberFormatWord

$number contains a number (may be calculated). If the number is between 1 and 12 the translated word will be returned. Otherwise fallbacks to __NFI[$number]

Examples
Macro Output
__NFW[10] ten
__NFW[1000] one thousand, zero
__NFW[1e20] one hundred quintillion, zero quadrillion, zero trillion, zero billion, zero million, zero thousand, zero

__PluralLabel[$label, $amount]

$label contains a reference to another language file entry. Is the given value for $amount (may be calculated) equal to 1 the referenced language entry will be translated and returned. If another value for $amount is given, the pluralized language entry will be translated and returned.

Examples
Macro Translated language key Output
__PluralLabel[building.opener, 1] building.opener Opener
__PluralLabel[building.opener, 10] building.opener.plural Openers

__KEY__

__KEY__ is a variable which is used to expand identical translations over multiple keys (mainly used for achievements and upgrade labels). Expanding requires adding the key to expand in the LanguageMiddleware. __KEY__ may be used in calculations.

An example language entry looks like: Build __NFI[__KEY__] buildings

Expanded this results in the following translations:

  • Build 100 buildings
  • Build 250 buildings
  • Build 500 buildings
  • Build 1.000 buildings
  • Build 1.500 buildings
  • Build 2.000 buildings
  • Build 3.000 buildings
  • Build 4.000 buildings
  • Build 5.000 buildings
  • Build 7.500 buildings
  • Build 10.000 buildings
  • Build 12.500 buildings
  • Build 15.000 buildings
  • Build 17.500 buildings
  • Build 20.000 buildings

Calculating Numbers

Numbers inside macros may be calculated using basic arithmetic. Addition, substraction, multiplication and division is supported as well as bracketing. Numbers with decimal places are supported (eg. 1.5). The usage of scientific notation is possible (eg. 2e25).

Examples
Macro Output
__NFI[10 * 2] 20
__NFI[1.5 * (2 + 4)] 9
__NFI[1e20 * 2] 200,000 Quintillion
Build __NFI[__KEY__ * 2] buildings
  • Build 200 buildings
  • Build 500 buildings
  • Build 1.000 buildings
  • Build 2.000 buildings
  • Build 5.000 buildings
  • Build 10.000 buildings
  • Build 20.000 buildings
  • Build 30.000 buildings
  • Build 50.000 buildings
  • Build 75.000 buildings
  • Build 100.000 buildings
  • Build 150.000 buildings
  • Build 250.000 buildings
  • Build 500.000 buildings
  • Build 1,000 Million buildings
  • Build 10,00 Million buildings
  • Build 100,0 Million buildings
  • 1 Plop
  • 10 Plops
  • 100 Plops
  • 1.000 Plops