Answers.Body: <p>Following on from comments, if this is custom code then you can use CRM.config.locale and hardcode the translation there, e.g.</p>
  <pre><code>var text = 'banana';
  if (CRM.config.locale == 'fr_FR') {
    text = 'banane';
  } elseif (CRM.config.locale == 'de_DE') {
    text = ... etc
  ...
  }
  theButton = 
    &quot;&lt;a id=thebutton href=/civicrm/contribute/transact/?reset=1&amp;id=6&gt;&quot; 
    + text 
    + &quot;&lt;/a&gt;&quot;;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-12T13:01:07.277Z
Answers.LastActivityDate: 2023-07-12T13:01:07.277Z
Answers.UserDisplayName: Demerit
Answers.Body: <p>Last I remember Administer - Customize - Word Replacements works for this it's just not obvious how to enter the text for the other languages. You need to switch to the language first then load the form. And the left hand side is always the en_US word.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-10T19:31:28.417Z
Answers.Text: Afraid this was the first thing I've tried in my naivety. Unfortunately this doesn't seem to be working for me at the moment.
Answers.UserDisplayName: yurg
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-10T20:04:42.697Z
Answers.Text: Oh ok maybe what I'm remembering is some work that was done to try to make it work that was not completed.
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-12T13:03:52.903Z
Answers.Text: This is what I was thinking of - it wasn't completed: https://github.com/civicrm/civicrm-core/pull/15836
Answers.UserDisplayName: Demerit
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-07-10T15:57:47.230Z
Answers.LastActivityDate: 2023-07-10T15:57:47.230Z
Answers.UserDisplayName: Demerit
Body: <p>There is a code added somewhere amongst Wordpress theme php files:</p>
  <pre><code>function functionFunction() {
    var ts = CRM.ts();
    theButton = 
    &quot;&lt;a id=thebutton href=/civicrm/contribute/transact/?reset=1&amp;id=6&gt;&quot; 
    + ts(&quot;The Button to translate&quot;) 
    + &quot;&lt;/a&gt;&quot;;
    return theButton;    
  }
  </code></pre>
  <p>A website is multisite + multilingual ( and none of the languages is English ), therefore <strong>The Button to translate</strong> needs to be translated to all enabled languages and be preserved during l10n updates.</p>
  <p>There are some recipies here <a href="https://explore.transifex.com/civicrm/civicrm/" rel="nofollow noreferrer">https://explore.transifex.com/civicrm/civicrm/</a> and  and here <a href="https://docs.civicrm.org/dev/en/latest/extensions/translation/#for-developers-generate-po-and-mo-files-for-your-extension" rel="nofollow noreferrer">https://docs.civicrm.org/dev/en/latest/extensions/translation/#for-developers-generate-po-and-mo-files-for-your-extension</a> and also here <a href="https://github.com/civicrm/civistrings" rel="nofollow noreferrer">https://github.com/civicrm/civistrings</a>
  and there <a href="https://civicrm.stackexchange.com/questions/16680/how-to-add-additional-custom-translation-for-a-payment-processor">How to add additional custom translation for a payment processor?</a>.</p>
  <p>However none of these addresses the situation where we need to translate a few lines of text without messing with MO/PO, gettext/poedit, etc., etc. It looks like  the closest one could get is to create an &quot;empty&quot; extension, the single purpose of which would be MO files accommodation - and even in this case we need to &quot;merge&quot; the extension translation file with the rest of it, which seems to be a bit too much for a small amount of text.</p>
  <p>Am I missing something here? Any alternatives/workarounds/hacks/fast&amp;dirty tricks?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-11T09:30:06.267Z
Comments.Text: That function is Javascript... is it really in your "theme php files"?
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-12T07:21:33.477Z
Comments.Text: @ChristianWach yes Sir, in wp-content/themes/mythemename/footer.php to be exact. Would it work if the code is moved somewhere else?
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-13T09:00:33.017Z
Comments.Text: Okay, so is the Javascript wrapped in a PHP function? I don't get how it would be used otherwise... indeed it would produce a PHP syntax error as it stands.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-13T09:05:38.523Z
Comments.Text: Ah, scrap that, I see - it's in a template file not e.g. `functions.php`... okay... so @Demerit's answer should work, but I can add an alternative that references the WordPress locale (since that's the canonical one) if that helps?
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-13T11:50:28.887Z
Comments.Text: One other thought: since you are working with a WordPress theme, it's worth getting to know how to apply localisation and internationalisation to the theme. A good starting point is http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ It's not a quick fix for your issue, but will make your life *much* easier in future when working with multilingual WordPress installs.
Comments.UserDisplayName: Christian Wach
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-13T14:18:16.333Z
Comments.Text: re: an alternative that references the WordPress locale - yes please! Though  @Demerit's solution works flawlessly  an alternative would be useful for those who prefers WordPress way of doing things.
Comments.UserDisplayName: yurg
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-07-19T14:43:44.113Z
Comments.Text: Sorry, bit busy right now - I'll have a go when I get a moment. At least you have a working solution for now :)
Comments.UserDisplayName: Christian Wach
Tags: <wordpress><translation><multilingual><l10n><transifex>
Title: Easy way of one word translation?
ThreadText: # Easy way of one word translation?
  
  (Asked by: username_0 on 2023-07-10)
  
  There is a code added somewhere amongst Wordpress theme php files:
  function functionFunction() {
    var ts = CRM.ts();
    theButton = 
    "" 
    + ts("The Button to translate") 
    + "";
    return theButton;    
  }
  
  A website is multisite + multilingual ( and none of the languages is English ), therefore The Button to translate needs to be translated to all enabled languages and be preserved during l10n updates.
  There are some recipies here https://explore.transifex.com/civicrm/civicrm/ and  and here https://docs.civicrm.org/dev/en/latest/extensions/translation/#for-developers-generate-po-and-mo-files-for-your-extension and also here https://github.com/civicrm/civistrings
  and there How to add additional custom translation for a payment processor?.
  However none of these addresses the situation where we need to translate a few lines of text without messing with MO/PO, gettext/poedit, etc., etc. It looks like  the closest one could get is to create an "empty" extension, the single purpose of which would be MO files accommodation - and even in this case we need to "merge" the extension translation file with the rest of it, which seems to be a bit too much for a small amount of text.
  Am I missing something here? Any alternatives/workarounds/hacks/fast&dirty tricks?
  
  **Tags:** wordpress, translation, multilingual, l10n, transifex
  
  > **Comments:**
  > **username_1**: That function is Javascript... is it really in your "theme php files"?  
  > **username_0**: @ChristianWach yes Sir, in wp-content/themes/mythemename/footer.php to be exact. Would it work if the code is moved somewhere else?  
  > **username_1**: Okay, so is the Javascript wrapped in a PHP function? I don't get how it would be used otherwise... indeed it would produce a PHP syntax error as it stands.  
  > **username_1**: Ah, scrap that, I see - it's in a template file not e.g. `functions.php`... okay... so @username_2's answer should work, but I can add an alternative that references the WordPress locale (since that's the canonical one) if that helps?  
  > **username_1**: One other thought: since you are working with a WordPress theme, it's worth getting to know how to apply localisation and internationalisation to the theme. A good starting point is http://ottopress.com/2012/internationalization-youre-probably-doing-it-wrong/ It's not a quick fix for your issue, but will make your life *much* easier in future when working with multilingual WordPress installs.  
  > **username_0**: re: an alternative that references the WordPress locale - yes please! Though  @username_2's solution works flawlessly  an alternative would be useful for those who prefers WordPress way of doing things.  
  > **username_1**: Sorry, bit busy right now - I'll have a go when I get a moment. At least you have a working solution for now :)  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2023-07-12. Score: 2 | Accepted answer
  
  Following on from comments, if this is custom code then you can use CRM.config.locale and hardcode the translation there, e.g.
  var text = 'banana';
  if (CRM.config.locale == 'fr_FR') {
    text = 'banane';
  } elseif (CRM.config.locale == 'de_DE') {
    text = ... etc
  ...
  }
  theButton = 
    "" 
    + text 
    + "";
  
  
  ---
  
  ### Answer by username_2 on 2023-07-10. Score: 1
  
  Last I remember Administer - Customize - Word Replacements works for this it's just not obvious how to enter the text for the other languages. You need to switch to the language first then load the form. And the left hand side is always the en\_US word.
  
  > **Comments:**
  > **username_0**: Afraid this was the first thing I've tried in my naivety. Unfortunately this doesn't seem to be working for me at the moment.  
  > **username_2**: Oh ok maybe what I'm remembering is some work that was done to try to make it work that was not completed.  
  > **username_2**: This is what I was thinking of - it wasn't completed: https://github.com/civicrm/civicrm-core/pull/15836  
  
  ---
  
  