handling leanguage change on editor
This commit is contained in:
parent
ca237ed837
commit
c88d0ba37c
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'ba8f00e47dc94991ab84');
|
||||
<?php return array('dependencies' => array('react', 'wp-block-editor', 'wp-blocks', 'wp-core-data', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'abacad7c685ec920b653');
|
||||
|
|
|
|||
|
|
@ -161,6 +161,24 @@ function Edit({
|
|||
const currentTaxonomies = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select("core/editor").getCurrentPostAttribute("thematiques"));
|
||||
let currentThematique = (0,_wordpress_data__WEBPACK_IMPORTED_MODULE_5__.useSelect)(select => select("core").getEntityRecord("taxonomy", "thematiques", currentTaxonomies[0] // or currentPost.thematiques[0] works as well
|
||||
), [currentTaxonomies]);
|
||||
function getAdminLanguageFromCookie(c_name) {
|
||||
var c_value = document.cookie,
|
||||
c_start = c_value.indexOf(" " + c_name + "=");
|
||||
if (c_start == -1) c_start = c_value.indexOf(c_name + "=");
|
||||
if (c_start == -1) {
|
||||
c_value = null;
|
||||
} else {
|
||||
c_start = c_value.indexOf("=", c_start) + 1;
|
||||
var c_end = c_value.indexOf(";", c_start);
|
||||
if (c_end == -1) {
|
||||
c_end = c_value.length;
|
||||
}
|
||||
c_value = unescape(c_value.substring(c_start, c_end));
|
||||
}
|
||||
return c_value;
|
||||
}
|
||||
const currentLang = getAdminLanguageFromCookie("wp-wpml_current_language");
|
||||
const localBlockName = currentLang === "fr" ? "Vocabulaire" : "Vocabulairen";
|
||||
(0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.useEffect)(() => {
|
||||
if (currentPost.content && currentBlocks) {
|
||||
const newTooltipWords = buildTooltipWords();
|
||||
|
|
@ -177,7 +195,7 @@ function Edit({
|
|||
})
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("h2", {
|
||||
className: "homegrade-blocks-vocabulaire-summary__title"
|
||||
}, "Vocabulaire \u2014", " ", currentThematique && currentThematique.name ? currentThematique.name : "{...pas de thématique}"), tooltipWords && tooltipWords.map(elem => (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("details", {
|
||||
}, localBlockName + " — ", currentThematique && currentThematique.name ? currentThematique.name : "...pas de thématique"), tooltipWords && tooltipWords.map(elem => (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("details", {
|
||||
className: "question"
|
||||
}, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("summary", null, elem.tooltipText, (0,_wordpress_element__WEBPACK_IMPORTED_MODULE_0__.createElement)("div", {
|
||||
className: "open-close-icon"
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -6,7 +6,7 @@ $thematique = get_the_terms($post->ID, 'thematiques')[0];
|
|||
|
||||
<section id="vocabulaire-summary" class="homegrade-blocks-vocabulaire-summary">
|
||||
<h2 className="homegrade-blocks-vocabulaire-summary__title">
|
||||
Vocabulaire <?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
<?php echo __("Vocabulaire", "homegrade-blocks") ?><?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
</h2>
|
||||
|
||||
<?php foreach ($tooltipWords as $word) : ?>
|
||||
|
|
|
|||
|
|
@ -132,7 +132,24 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
),
|
||||
[currentTaxonomies]
|
||||
);
|
||||
|
||||
function getAdminLanguageFromCookie(c_name) {
|
||||
var c_value = document.cookie,
|
||||
c_start = c_value.indexOf(" " + c_name + "=");
|
||||
if (c_start == -1) c_start = c_value.indexOf(c_name + "=");
|
||||
if (c_start == -1) {
|
||||
c_value = null;
|
||||
} else {
|
||||
c_start = c_value.indexOf("=", c_start) + 1;
|
||||
var c_end = c_value.indexOf(";", c_start);
|
||||
if (c_end == -1) {
|
||||
c_end = c_value.length;
|
||||
}
|
||||
c_value = unescape(c_value.substring(c_start, c_end));
|
||||
}
|
||||
return c_value;
|
||||
}
|
||||
const currentLang = getAdminLanguageFromCookie("wp-wpml_current_language");
|
||||
const localBlockName = currentLang === "fr" ? "Vocabulaire" : "Vocabulairen";
|
||||
useEffect(() => {
|
||||
if (currentPost.content && currentBlocks) {
|
||||
const newTooltipWords = buildTooltipWords();
|
||||
|
|
@ -150,10 +167,10 @@ export default function Edit({ attributes, setAttributes }) {
|
|||
})}
|
||||
>
|
||||
<h2 className="homegrade-blocks-vocabulaire-summary__title">
|
||||
Vocabulaire —{" "}
|
||||
{localBlockName + " — "}
|
||||
{currentThematique && currentThematique.name
|
||||
? currentThematique.name
|
||||
: "{...pas de thématique}"}
|
||||
: "...pas de thématique"}
|
||||
</h2>
|
||||
{tooltipWords &&
|
||||
tooltipWords.map((elem) => (
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ $thematique = get_the_terms($post->ID, 'thematiques')[0];
|
|||
|
||||
<section id="vocabulaire-summary" class="homegrade-blocks-vocabulaire-summary">
|
||||
<h2 className="homegrade-blocks-vocabulaire-summary__title">
|
||||
Vocabulaire <?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
<?php echo __("Vocabulaire", "homegrade-blocks") ?><?php echo $thematique->name ? " — " . $thematique->name : ""; ?>
|
||||
</h2>
|
||||
|
||||
<?php foreach ($tooltipWords as $word) : ?>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user