Skip to content

Instantly share code, notes, and snippets.

import locale
import datetime
locale.setlocale( locale.LC_ALL, 'en_US' )
// va afficher : '$188518982.18'
locale.currency( 188518982.18 )
// va afficher '1,255,000'
@hlassiege
hlassiege / formatcurrency.txt
Created May 3, 2018 09:27
formatcurrency.txt
CultureInfo ci = CultureInfo.CurrentCulture;
string money = 120.ToString(“c”,ci);
@hlassiege
hlassiege / formatdate.txt
Created May 3, 2018 09:27
formatdate.txt
string myDate = DateTime.Now.ToString(ci);
@hlassiege
hlassiege / formatwithpear.php
Created May 3, 2018 09:28
formatwithpear.php
require_once 'I18Nv2.php';
$locale = &I18Nv2::createLocale('en_US');
echo "Format a currency value of 2000: ",
$locale->formatCurrency(2000, I18Nv2_CURRENCY_INTERNATIONAL), "\n";
echo "Format todays date: ",
$locale->formatDate(null, I18Nv2_DATETIME_FULL), "\n";
@hlassiege
hlassiege / getculturecsharp.txt
Created May 3, 2018 09:28
getculturecsharp.txt
Culture culture = CultureInfo.CurrentCulture ;
@hlassiege
hlassiege / getdefaultlocale.php
Created May 3, 2018 09:28
getdefaultlocale.php
locale_get_default()
// ou
Locale::getDefault()
@hlassiege
hlassiege / getdefaultlocale.py
Created May 3, 2018 09:28
getdefaultlocale.py
l = locale.getdefaultlocale()
@hlassiege
hlassiege / getstring.java
Created May 3, 2018 09:29
getstring.java
ResourceBundle rb = ResourceBundle.getBundle("myBundle", currentLocale);
String message = rb.getString("string1");
@hlassiege
hlassiege / getstring.php
Created May 3, 2018 09:29
getstring.php
$rb = new ResourceBundle('root', "./locale");
echo resourcebundle_get($rb, 'string1');
ou
echo $r->get('string1');
@hlassiege
hlassiege / gettext.py
Last active May 3, 2018 09:29
gettext.py
import gettext
print _("Hello, World!")