KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Defining User Constants for Currency Symbols in v13 with XLIFF
PRODUCT: 4D | VERSION: 13.0 | PLATFORM: Mac & Win
Published On: June 2, 2012


When displaying currency on a page 4D will automatically handle changing the thousands and decimal delimiter characters based on the OS Regional settings . However, if a currency character is included in the formate string 4D will not make any changes to it.

Display and placement of currency symbols is the responsibility of the developer. In 4D v13 it is very easy to use create an XLIFF constants file and use them for displaying currency symbols.

At the bottom is the contents of an XLIFF file that does a limited implementation of international currency symbols. The code below show how to use the constants. It is the developers responsibility to know the placement, before or after, of the currency symbol. As shown some regions place the Euro symbol before the number, others after.

NOTE: This techniques assumes that the database is in UNICODE mode.

$MyString_T:=Char(Dollar Sign)+String(123456.01;"###,###,##0.00")
"$123,456.01"

$MyString_T:=Char(Euro Sign)+String(123456.01;"###,###,##0.00")
"€123,456.01"

$MyString_T:=String(123456.01;"###,###,##0.00")+" "+Char(Euro Sign)
"123,456.01 €"

$MyString_T:=Char(Pound Sign)+String(123456.01;"###,###,##0.00")
"£123,456.01"

$MyString_T:=String(123456.01;"###,###,##0.00")+" "+Char(Shekel Sign)
"123,456.01 ₪"



Below is the contents of the file "Currency_Symbols.xlf" that was created using the v13 4D Pop Constants component.

<?xml version="1.0" encoding="UTF-8" standalone="no" ?>
<xliff version="1.0" xmlns:d4="https://www.4d.com/d4-ns">
<!--
  Created with 4DPop Constants Editor
 -->
 <file datatype="x-4DK#" original="x-undefined" source-language="x-none" target-language="x-none">
  <header>
   <prop-group name="4DPop Constant editor">
    <prop prop-type="version"13.0</prop>
   </prop-group>
  </header>
  <body>
<!--groups' labels-->
   <group resname="themes">
    <trans-unit id="thm_1" resname="FDE3CFF0A7EE410EBE683409C048E13A" translate="no">
     <source>Currency</source>
    </trans-unit>
   </group>
<!--constants-->
   <group d4:groupName="FDE3CFF0A7EE410EBE683409C048E13A" restype="x-4DK#">
    <trans-unit d4:value="162" id="k_1">
     <source>Cent Sign</source>
    </trans-unit>
    <trans-unit d4:value="164" id="k_2">
     <source>Currency Sign</source>
    </trans-unit>
    <trans-unit d4:value="36" id="k_3">
     <source>Dollar Sign</source>
    </trans-unit>
    <trans-unit d4:value="8364" id="k_4">
     <source>Euro Sign</source>
    </trans-unit>
    <trans-unit d4:value="163" id="k_5">
     <source>Pound Sign</source>
    </trans-unit>
    <trans-unit d4:value="165" id="k_6">
     <source>Yen Sign</source>
    </trans-unit>
    <trans-unit d4:value="1547" id="k_7">
     <source>Afgani Sign</source>
    </trans-unit>
    <trans-unit d4:value="8362" id="k_8">
     <source>Shekel Sign</source>
    </trans-unit>
    <trans-unit d4:value="8361" id="k_9">
     <source>Won Sign</source>
    </trans-unit>
    <trans-unit d4:value="8355" id="k_10">
     <source>Franc Sign</source>
    </trans-unit>
    <trans-unit d4:value="8377" id="k_11">
     <source>Rupee Sign</source>
    </trans-unit>
   </group>
  </body>
 </file>
</xliff>