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) »
  • Customise a few strings
Pages: [1]

Author Topic: Customise a few strings  (Read 1406 times)

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Customise a few strings
October 03, 2012, 05:50:54 pm
I want to customise just a few strings that are being passed through the 'ts' function.

Ideally, I'd do something like in Drupal where for ad-hoc string customisations you can add entries into the settings.php file.

At this point, I've created an entirely new translation with just the one entry which has been a lot of work getting it into the correct format. And on upgrade, unless I remember, I'm likely to lose this 'translation'.

Is there a better way?

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Re: Customise a few strings
October 04, 2012, 11:22:15 am
http://book.civicrm.org/user/current/initial-set-up/customizing-the-user-interface and scroll down to the very bottom

torrance123

  • I post occasionally
  • **
  • Posts: 57
  • Karma: 3
  • CiviCRM version: 4.0
  • CMS version: Drupal 7
  • MySQL version: 5.0.91
  • PHP version: 5.3.3
Re: Customise a few strings
October 10, 2012, 04:20:19 pm
Hi demeritcowboy,

Thanks for the pointer. Unfortunately, the word replacement doesn't seem to work for my use case.

I'm trying to replace the error string "This email %1 is already registered. Please select another email." with something more helpful, eg. "It looks like you already have an account with us registered with the email address %1.  <a href=\"/user/password\">Click here to request a new password</a> and login before proceeding."

I tried entering the original string and the replacement, but the original string wasn't being substituted.

I *can* do this by creating a new translation, eg, en_CUSTOM but it seems very heavy handed (and in our case, prone to being deleted next upgrade of civi).

Erik Hommel

  • Forum Godess / God
  • I live on this forum
  • *****
  • Posts: 1773
  • Karma: 59
    • EE-atWork
  • CiviCRM version: all sorts
  • CMS version: Drupal
  • MySQL version: Ubuntu's latest LTS version
  • PHP version: Ubuntu's latest LTS version
Re: Customise a few strings
October 10, 2012, 11:21:13 pm
The quick and dirty way is to check where in the code the message is used and replacing it directly in the code. It goes without saying that is a hackish solution and requires attention at every upgrade. So I would not advocate it, but you can use it. Obviously if you do this you should have your own copy of whatever script you changed in your custom php folder.

Another trick you might want to use is to create your own specific .PO file with translations? (check the documentation http://help.transifex.com/features/formats.html#po-files). That would probably be the recommended approach.

Final option as far as I can see is to fix the problem with the Word Replacement if you can?

Consultant/project manager at EEatWork and CiviCooP (http://www.civicoop.org/)

mathieu

  • Administrator
  • Ask me questions
  • *****
  • Posts: 620
  • Karma: 36
    • Work
  • CiviCRM version: 4.7
  • CMS version: Drupal
  • MySQL version: MariaDB 10
  • PHP version: 7
Re: Customise a few strings
October 17, 2012, 06:39:39 am
We should also consider fixing core to improve those error messages in general. It's a small change, but I think it would benefit to CiviCRM's usability.

I recommend against using custom .po files, because they are difficult to upgrade to future civicrm versions. The site either gets stuck with its old .po file (and then new strings are not included), or re-patch the .po on upgrades, or gettext merge strings on upgrade. At that point, you may as well patch core, it's the same, but less fiddling around.

Another option is to use a custom translation function and to implement your known string replacements. Although, as Erik said, might be better to find why it's not working to beginning with, the code for ts() mostly in CRM/Core/I18n.php, see function crm_translate().
CiviCamp Montréal, 29 septembre 2017 | Co-founder / consultant / turn-key CiviCRM hosting for Quebec/Canada @ SymbioTIC.coop

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Internationalization and Localization (Moderators: Michał Mach, mathieu) »
  • Customise a few strings

This forum was archived on 2017-11-26.