Difference between revisions of "Translation Macros"

From Beerplop
 
(5 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=== Variables ===
+
===Variables===
 
Translations may contain variables which are filled from the application.
 
Translations may contain variables which are filled from the application.
  
Line 115: Line 115:
 
*Build 500 buildings
 
*Build 500 buildings
 
*Build 1.000 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===
 
===Calculating Numbers===
Line 149: Line 139:
 
*Build 1.000 buildings
 
*Build 1.000 buildings
 
*Build 2.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
 
 
|}
 
|}

Latest revision as of 09:14, 25 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

__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] 1.000
__NFW[1e20] 100,000 Quintillion

__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
  • ...

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
  • ...