{"id":8031,"date":"2023-08-14T13:14:51","date_gmt":"2023-08-14T20:14:51","guid":{"rendered":"https:\/\/membermouse.com\/?post_type=ht_kb&#038;p=8031"},"modified":"2024-08-12T16:06:32","modified_gmt":"2024-08-12T20:06:32","slug":"translate-membermouse-advanced","status":"publish","type":"ht_kb","link":"https:\/\/membermouse.com\/fr\/docs\/translate-membermouse-advanced\/","title":{"rendered":"Traduire MemberMouse - Avanc\u00e9"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">MemberMouse includes support for localization, and by default loads a US English translation for use with the plugin. It\u2019s possible to translate most text in the MemberMouse backend to the language of your choice using WordPress\u2019 built-in localization feature. This is in addition to being able to create member-facing content in the language of your choice with few exceptions. These are detailed in the second half of this article.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The simplest way to add support for additional languages is to use a localization plugin and the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/membermouse.com\/docs\/translate-membermouse-basic\/\" target=\"_blank\">Translate MemberMouse &#8211; Basic<\/a>&nbsp;article walks through the steps for that approach. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">But if there is more specific customization you'd like to achieve, support can also be added programmatically using a small amount of code.&nbsp;While this code can be placed in many different locations, it is probably best to create a small plugin dedicated to translation, which is what will be demonstrated in this article and explained in more detail below.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Translate MemberMouse Backend &#8211; Advanced<\/strong><\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">In order to translate the backend from English to the language of your choice, you will need to create a&nbsp;translation file or &#8220;Localization&#8221; file. The&nbsp;file that holds this translation is appended by .po \/ .mo, where .po is the editable file and the .mo is the compiled version. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">By defining a proper configuration, WordPress will use this file to do the work based on the language selected.&nbsp;Localization using .po \/ .mo files is a basic way to translate phrase \u201cx\u201d to phrase \u201cy\u201d in the new respective language. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If done correctly, you might have something like the following:<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p class=\"wp-block-paragraph\">English\/Spanish Example:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u201cHow are you?\u201d = \u201cComo Estas?\u201d<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n<\/blockquote>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>How it works: Construction of a .po file<\/strong><\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">The .po file is really a simple file that does the translation as mentioned above.&nbsp;The language file is typically named in the following manner:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>[text-domain]-[language-prefix]_[Country]<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">text-domain: mm (Our plugin has a text domain of \u201cmm\u201d by default.)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">language-prefix:&nbsp;<a href=\"http:\/\/www.gnu.org\/software\/gettext\/manual\/gettext.html#Language-Codes\" target=\"_blank\" rel=\"noreferrer noopener\">List of Language-Codes<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Country:&nbsp;<a href=\"http:\/\/www.gnu.org\/software\/gettext\/manual\/gettext.html#Country-Codes\" target=\"_blank\" rel=\"noreferrer noopener\">List of Country-Codes<\/a><\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Ex. If you want to translate to German and are located in Germany, the file name would be: mm-de_DE<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A typical basic file might look something like the following:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>File: mm-es_ES.po<\/strong><\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>msgid \"\"\n\nmsgstr \"\"\n\n\"Project-Id-Version: Spanish Version 1.0\\n\"\n\n\"POT-Creation-Date: \\n\"&nbsp;\n\n\"PO-Revision-Date: \\n\"&nbsp;\n\n\"Last-Translator: \\n\"&nbsp;\n\n\"Language-Team: MemberMouse &lt;support@membermouse.com&gt;\\n\"&nbsp;\n\n\"MIME-Version: 1.0\\n\"\n\n\"Content-Type: text\/plain; charset=iso-8859-1\\n\"&nbsp;\n\n\"Content-Transfer-Encoding: 8bit\\n\" \"Language: es_ES\\n\"\n\n\"X-Generator: Poedit 1.8.8\\n\"&nbsp;\n\n\"Plural-Forms: nplurals=2; plural=(n != 1);\\n\"\n\n\"X-Poedit-SourceCharset: UTF-8\\n\"\n\nmsgid \"How are you?\"&nbsp;\n\nmsgstr \"Como Estas?\"<\/code><\/pre>\n\n\n\n<div style=\"height:8px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">As you can see the&nbsp;<em>msgid<\/em>&nbsp;is the text to be translated and the&nbsp;<em>msgstr<\/em>&nbsp;is the resultant translated phrase.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Atop of the translation, is just some metadata to help define the language and version.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Additional Information:<\/strong>&nbsp;There is some reading on plural forms found here:&nbsp;<a href=\"https:\/\/poedit.net\/trac\/wiki\/Doc\/PluralForms\" target=\"_blank\" rel=\"noreferrer noopener\">Poedit Plural Forms<\/a><a href=\"https:\/\/poedit.net\/trac\/wiki\/Doc\/PluralForms\" target=\"_blank\" rel=\"noreferrer noopener\"><\/a><\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Advanced Translation Setup<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>NOTE:<\/strong>&nbsp;The following contains advanced steps that will take time, effort and planning to accomplish:<\/p>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<ol class=\"wp-block-list\">\n<li><em><strong>Download MemberMouse<\/strong><\/em>&nbsp;&#8211; The first step is to obtain the&nbsp;<a rel=\"noreferrer noopener\" href=\"http:\/\/hub.membermouse.com\/download.php\" target=\"_blank\">latest version of MemberMouse<\/a>. This will prompt you to save a zip file named membermouse.zip. Place this file in a known location that you have read and write access to.<br><br><\/li>\n\n\n\n<li><em><strong>Create a folder for the new plugin<\/strong><\/em>&nbsp;&#8211; The next step is to create a folder\/directory on the local filesystem to hold the files we will create for our new plugin. The folder can be named anything. For this example we will use the name membermouse-translation.<br><br><\/li>\n\n\n\n<li><em><strong>Unzip the MemberMouse Plugin<\/strong><\/em>&nbsp;&#8211; After the \u201cmembermouse-translation\u201d folder has been created, locate the MemberMouse plugin downloaded in step 1, and unzip the plugin into a known location. The unzip process will create a folder named \u201cmembermouse\u201d<strong>.<\/strong><br><br><\/li>\n\n\n\n<li><em><strong>Copy the language files into the new plugin's folder<\/strong>&nbsp;<\/em>\u2013 Inside of the &#8220;membermouse&#8221; folder that was created above, will be another folder called \u201clanguages\u201d. This folder needs to be copied into the \u201cmembermouse-translation\u201d folder.<br><br><\/li>\n\n\n\n<li><em><strong>Download the Poedit application<\/strong><\/em>&nbsp;\u2013 Poedit is a free application used to edit translation files for applications that use gettext (like WordPress). The latest version can be downloaded from here:&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/poedit.net\/\" target=\"_blank\">POEdit Download<\/a> &nbsp;<br><br><\/li>\n\n\n\n<li><em><strong>Create a New Translation<\/strong>&nbsp;<\/em>&#8211; Open the Poedit application, and choose \u201cCreate New Translation\u201d from the main screen, and select the membermouse.po file in the membermouse-translation\/languages folder.<br><br><img decoding=\"async\" class=\"wp-image-11006\" style=\"width: 450px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/61416bf4-create-new-translation.png\" alt=\"\"><br><br><\/li>\n\n\n\n<li><strong><em>Select Language to Translate to&nbsp;<\/em><\/strong>&#8211; In the next dialog that appears, select the language you would like to create a translation for (Note: if you just want to customize some of the English labels, select English(US) from the dropdown). <br><br><img decoding=\"async\" class=\"wp-image-11011\" style=\"width: 800px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/619fdde4-language-selection.png\" alt=\"\"><br><br><\/li>\n\n\n\n<li><strong><em>Translate Desired Text Fields<\/em><\/strong>&nbsp;&#8211; Selecting your desired language will open a window with all of the text available for translation in a scrolling area. Select the items you wish to translate, and in the \u201cTranslation\u201d textbox, type the translated text. <br><br><img decoding=\"async\" class=\"wp-image-11010\" style=\"width: 600px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/9181499a-translated-text.png\" alt=\"\"><br><br> &nbsp;<\/li>\n\n\n\n<li><strong><em>Save the New Translation<\/em><\/strong>&nbsp;&#8211; When you are satisfied with your translation, go to the File menu, choose \u201cSave As\u201d and save the new .po for your language in the languages folder. <br><br>The format of this file is very important, it should be \u201cmembermouse-&lt;locale&gt;.po\u201d. <br><br>Fortunately, Poedit will pre-populate the filename field with the correct locale for the language you selected, so you just need to add \u201cmembermouse-\u201d in front of that. For example, for English(US), Poedit will pre-populate the filename field with \u201cen_US.po\u201d, so adding \u201cmembermouse-\u201d yields the filename \u201cmembermouse-en_US.po\u201d. <br><br>Once the filename has been entered correctly, save the new .po file in the membermouse-translation\/languages folder. If the language is English(US), it will ask if you want to overwrite the existing .po file, answer yes to this. <br><br><img decoding=\"async\" class=\"wp-image-11009\" style=\"width: 450px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/a76beef2-saveas.png\" alt=\"\"><br><br><br>After the .po file has been saved, go to the File menu and select \u201cCompile to .mo\u201d. Create a .mo file in the membermouse-translation\/languages with the same name as the .po file, with the extension changed to .mo. <br><br>For example, using English(US), create a .mo file named \u201cmembermouse-en_US.mo\u201d.<br><br><img decoding=\"async\" class=\"wp-image-11008\" style=\"width: 200px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/7be102e0-screen-shot-2016-09-30-at-5.58.43-pm.png\" alt=\"\"><br><br><br><img decoding=\"async\" class=\"wp-image-11007\" style=\"width: 400px;\" src=\"https:\/\/storage.googleapis.com\/wpgcbucket\/wp\/2023\/10\/4e723941-mosave.png\" alt=\"\">&nbsp;&nbsp;<br><br><\/li>\n\n\n\n<li><strong><em>Create the main plugin file&nbsp;<\/em><\/strong>&#8211; Create a file in the membermouse-translation folder named membermouse-translation.php. <br><br>The code that will be placed in this file is mostly WordPress plugin boilerplate code, with a special block added in to substitute in the translation created in the previous step when MemberMouse attempts to load its translation files. <br><br>Add the following code to the file: <br><br><code>&lt;?php<br>\/*<br>Plugin Name: MemberMouse Translation<br>Plugin URI: https:\/\/membermouse.com\/<br>Description: A translation for MemberMouse<br>Version: 1.0<br>*\/<br>function membermouse_translation_override_load_textdomain($mofile, $domain)<br>{<br>if ('membermouse' === $domain) {<br>return plugin_dir_path(__FILE__).'languages\/membermouse-<br>en_US.mo'; }<br>return $mofile;<br>}<br>add_filter( 'load_textdomain_mofile','membermouse_translation_override_load<br>_textdomain', 10, 2 );<\/code><br><br><br><\/li>\n\n\n\n<li>&nbsp;<strong><em>Modify the code as needed<\/em><\/strong>&nbsp;&#8211; If the .mo file for the new translation is different than the one in the membermouse-translation.php file, modify the line that reads <br><br><br><code>return plugin_dir_path(__FILE__).'languages\/membermouse-en_US.mo';<\/code><br><br><br>and change \u201cmembermouse-en_US.mo\u201d to match the .mo file created in step 7.<br><br><\/li>\n\n\n\n<li><strong><em>Zip and Install the New Plugin<\/em><\/strong>&nbsp;\u2013 Create a compressed zip file named \u201cmembermouse-translation.zip\u201d that contains the folder \u201cmembermouse-translation\u201d and its contents. <br><br>This zip is now a fully-functioning WordPress plugin that can be installed to override the default translation! <br><br>You would simply install this updated plugin following the same steps outlined in the article&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/membermouse.com\/docs\/installing-membermouse\/\" target=\"_blank\">Installing MemberMouse<\/a><\/li>\n<\/ol>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h5 class=\"wp-block-heading\">Translate Member-Facing Content<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">Most of the things that your customers will be interacting with via your website and member portal can be translated as the majority of customer-facing content that MemberMouse creates is simply HTML text that can be modified via the WordPress editor. <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In older versions of MemberMouse prior to 3.0.6, there are a few instances where items can either not be translated or require more coding than changing the HTML to translate. Wherever possible, we've suggested other methods of translating these elements.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h6 class=\"wp-block-heading\">Version 2.0 to 3.0.5 &#8211; Elements able to be translated with additional coding:<\/h6>\n\n\n\n<div style=\"height:5px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">1. <strong>Error messages<\/strong>&nbsp;generated by MemberMouse or error messages received from 3rd parties, such as the payment service provider.<br><br>If you are technically inclined you can customize this message to appear in another language. The&nbsp;<a href=\"https:\/\/membermouse.com\/docs\/customize-error-messages-on-the-checkout-page\/\">Customize Error Messages on the Checkout Page<\/a>&nbsp;article provides additional information on how to do this. You'll note in this article that you can translate the 3rd party error messages only if you know the specific error message received from the 3rd party that you want to translate.<br><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">2. <strong>The product price description<\/strong>.&nbsp;One option would be to use the&nbsp;<a rel=\"noreferrer noopener\" href=\"https:\/\/membermouse.com\/docs\/order-decision-smarttag-mm_order_decision\/\" target=\"_blank\">Order_Decision SmartTag<\/a>&nbsp;to define alternate descriptions for specific products. &nbsp;<br><br>For each product you want to include a translation for, you can add a line directly below the SmartTag\u2122 (or replace the SmartTag\u2122 all together if you include one for each product) using the SmartTag\u2122 to filter the description by ID: <\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;MM_Order_Decision productId='#'] \nYour translated product price description here \n&#91;\/MM_Order_Decision] <\/code><\/pre>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Another workaround would be to create product-specific custom checkout pages and replace the&nbsp;MM_Form_Data name='productPriceDescription' SmartTag with text in your language describing the pricing for that product. The&nbsp;<a href=\"https:\/\/membermouse.com\/docs\/create-a-custom-checkout-page\/\">Create a Custom Checkout Page<\/a>&nbsp;article provides additional information on how to do this.<br><br><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">3. <strong>The payment processing message<\/strong>&nbsp;on the checkout page that displays after a customer has submitted their order. &nbsp;You can customize this message to appear in another language by following the information provided in&nbsp;<a href=\"https:\/\/membermouse.com\/docs\/customize-the-checkout-page-processing-message\/\">Customize the Checkout Page Processing Message<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Because messages coming from 3rd party vendors, such as payment service providers, are received and then directly output by MemberMouse onto the screen, if you do not know the specific error message from the 3rd party vendor, then this will not be able to be translated.<\/p>\n\n\n\n<div style=\"height:10px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n","protected":false},"excerpt":{"rendered":"<p>MemberMouse prend en charge la localisation et charge par d\u00e9faut une traduction en anglais am\u00e9ricain \u00e0 utiliser avec le plugin. Il est possible de traduire la plupart des textes du backend de MemberMouse...<\/p>","protected":false},"author":20918,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"_acf_changed":false,"om_disable_all_campaigns":false,"_strive_editorial_status":"not-started","_strive_copy_of":0,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"ht-kb-category":[160],"ht-kb-tag":[],"class_list":["post-8031","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-customize-mm"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb\/8031","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/users\/20918"}],"replies":[{"embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/comments?post=8031"}],"version-history":[{"count":0,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb\/8031\/revisions"}],"wp:attachment":[{"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/media?parent=8031"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb-category?post=8031"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/membermouse.com\/fr\/wp-json\/wp\/v2\/ht-kb-tag?post=8031"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}