CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Date and currency formatting function in extensions
Pages: [1]

Author Topic: Date and currency formatting function in extensions  (Read 862 times)

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Date and currency formatting function in extensions
October 23, 2013, 06:28:42 am
Hey all,

Today I was working on extension for adding tokens for the last contribution and the last contribution date.
This all worked but then my client asked if the date and the currency formatting could be displayed in the Norwegian locale (my client was from Norway).
So he wanted that dates would be formatted to
21. Mars 2013 and the currency to NOK 3 456,22 or NOK 456 (no decimals if there weren't).

My first thought was to use core functionality to format those dates and numbers so that the formatting depends on the settings and the locale of Civi.
This all seemed to work on my local dev environment but after putting on the test environment of my client (which had the same civi settings) the currency was formatted differently then my local dev.
And on my local dev and on test the names of the month where still in English. So for this extension I had to write my own formatting function which seems to be a pitty to do.

I have used the class CRM_Utils_Money and CRM_Utils_Date for formatting the money and currency.

Is there a way to use locale settings in my extension? Or is this not function correctly in core? (My CiviCrM version 4.3.5)

Thanks,
Jaap
Developer at Edeveloper / CiviCoop

jaapjansma

  • I post frequently
  • ***
  • Posts: 247
  • Karma: 9
    • CiviCoop
  • CiviCRM version: 4.4.2
  • CMS version: Drupal 7
  • MySQL version: 5
  • PHP version: 5.4
Re: Date and currency formatting function in extensions
February 18, 2014, 02:36:54 am
I ended up wit writing my own custom formatting code into the tokens.
Developer at Edeveloper / CiviCoop

JoeMurray

  • Administrator
  • Ask me questions
  • *****
  • Posts: 578
  • Karma: 24
    • JMA Consulting
  • CiviCRM version: 4.4 and 4.5 (as of Nov 2014)
  • CMS version: Drupal, WordPress, Joomla
  • MySQL version: MySQL 5.5, 5.6, MariaDB 10.0 (as of Nov 2014)
Re: Date and currency formatting function in extensions
May 03, 2014, 04:05:33 pm
We've had some troubles with localization working differently on different machines for character encodings during exporting and importing. While not exactly the same, we found that OS locale and PHP locale - three different settings if I recall correctly - needed to be set correctly when we were doing some writing to file then invoking a script to do something with the file.
Co-author of Using CiviCRM https://www.packtpub.com/using-civicrm/book

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Date and currency formatting function in extensions

This forum was archived on 2017-11-26.