Questions tagged as ['i18n-l10n']
I have a multilingual website with taxonomy vocabulary, which terms are not translatable (company names).
But each term has translated meta tags and paths, depending on the selected site language.
For example, term paths:
- /vocab-name/term-name (default, english)
- /de/vocab-name/term-name
- /es/vocab-name/term-name
- /it/vocab-name/term-name
- etc
I can access all of them, metatags are displayed in the c ...

I'm trying to catch multilingual features of Drupal 9 and have wamp64 local development server and clean Drupal 9.2.8 install.
I've enabled 4 multilingual core modules:
- Configuration Translation,
- Content Translation,
- Interface Translation,
- and Language.
Two languages enabled: en and ru.
I'm trying to translate Main Navigation Menu, but menu items don't have a "translate" button along with "edit" ...

I am translating the nodes programmatically. Everything works fine except the layout builder blocks.
When I try to translate it, it also changes on the source node.
I have created a node in language en
. Now I am translating it to nl
. Here is my code.
if ($node->hasTranslation($language)) {
$translated_entity = $node->getTranslation($language);
}
else {
$translated_entity = $entity->a ...
I have Content Translate enabled and enabled translation on only our Projects content type. I've placed the Language switcher block on a Projects view and Project node page. This is working just fine.
My problem is, if I use the Language switcher on the Projects view for Project page, then click a link in the main menu to a pieces of non-Project content, the path has changed to /es/node/1
when it should ...
I'm on Drupal 9. I need to load the options labels of a Webform's option programmatically.
So far, I've managed to load the labels:
$element = $webform_submission->getWebform()
->getElement($element_key, TRUE);
$option_text = WebformOptionsHelper::getOptionText($element_value, $element['#options']);
However, I also need to get those labels for both the language of the site - en
and

I have an "About us" main-navigation menu link.
I want to create several other main-navigation menu links, in languages other than English, which will link to that very webpage, for example:
- เกี่ยวกับเรา (about us in Thai)
- If the user clicked that link, the destination would be the same "About us" webpage, but the content would be machine-translated to Thai.
The English cont ...

I need some help on a multilingual D9 site, trying to add links to translated node in text field. In German version should be a link to the English and French version of this node, as part of the node content.
And I need them absolute, because the nodes are used as newsletter content: https://example.de/en/node/123
I created link with language part in url, but when I view the node, the links are re ...
Our client does not need their entire website to be translated into multiple languages. However, they have a webform that provides a number of different languages in a dropdown, and would like the form labels to be displayed in the chosen language.
Creating multiple versions of the form would be a maintenance headache. Is there a way to tap into Webform and Drupal's localization facilities withou ...

admin/config/regional/language/detection/url
I selected the "domain" option, and set my english to example.com and my french to french-example.com. When I saved the page, I got the error, "Redirects to external URLs are not allowed by default, use \Drupal\Core\Routing\TrustedRedirectResponse for it."
Even though I got that error, it seemed as though the pages were redirecting to the french domain, ...
I'm trying to get a list of language translations that a node has in theme_preprocess_node()
. I have the node object and can check for a translation on a one-by-one basis, if I have the list of languages. What I need is a list of all the translations for the node.
I have a view that filters content (films) by category and it works as expected.
I've added a new language to the site and some categories are not applied in both languages to the same content, but the view returns all the films that have that category in the main language, even if it doesn't have that category in current language.
For example, if I have a film with these categories in English:
- S ...
Note: This question is only focused on strings inside source files (PHP files).
When you are creating a Drupal site in a non English country (let say France), you will create all your PHP files with French strings inside.
After that, you can translate this site, let say in Dutch. You will extract PO files, send them into translation an re-import them.
Until this point, everything is fine.
Now, your client ...
I'm setting up a multilingual site, and I need the user path aliases to be multilingual.
Users are set up as translatable:
Language Detection: URL (path prefix)
- English:
/en
- Japanese: No prefix
Pathauto patterns:
- English:
/en/users/[user:name]
- Japanese: '
/users/[user:name]
Example:
- Username: Admin
Expected paths:
- English:
/en/users/admin
- Japanese:
/users/admin
Actual:
- English:
/en/user/1
I have a content type Products. A pattern is defined via the Pathauto module for product CT. but my issue is that when I translate an entry/node it generates a translated path alias for Urdu in Roman-English(Urdu in English alphabet) But the spellings of that path are meaningless. When I uncheck "Transliterate prior to creating alias" It generates the aliases in pure Urdu which is unacceptable in my ...
I'm new to using Drupal and am building a custom module to learn how it all works.
I'm building my module in modules/custom/my_module
. I have a Dutch locale file in modules/custom/my_module/translations/my_module-0.1.nl.po
.
If I specify it like that in my .info.yml
file, it works great:
name: My Module
description: Just testing
version: 0.1
package: Custom
type: module
core_version_requirement: ^8.8 || ^9 ...
I'm implementing hook_form_BASE_FORM_ID_alter() in a custom module. I'd like to know if my form is for the node in its default language, or a translation of that original node.
On the Language Selection and Detection configuration page (in the toolbar, Manage > Configuration > Regional and language > Languages > Selection and Detection), I see that I can detect and set "Interface text language" and "Content language" differently. But I don't see a clear definition of those terms anywhere.
I have a hardcoded heading within a node template:
<h2>{{ "Hello worl ...
I'm trying to set up an English administrator back-end and a URL based front-end (anonymous user content) translation. I follow a guide on the subject, but I haven't been able to achieve what I wanted.
I also tried to set up /admin/config/regional/language/detection using various combinations of settings, but either I have the back-end in English along with the rest of the site, or everything is ...
I have created a content type (pdf_form) to which I added a field_gender_languagetest with two options, male and female. I translated both the options in German using the translation tab.
Now I am generating a report of the data filled by users using that content type.
Is there any way to programmatically get that translation?
I am trying this code, but it doesn't work.
t('male', array(), array('langcod ...
I need own translation function in my custom module where i have defined language codes ('en','ja','de'....etc) Now i just wanted to pass word and language code as a parameter and it returns translation of that word according to language code.
I am trying this inside my translation but it doesn't work it is returning 'yes' instead i don't know why.
$japanese_value = t('yes', array(), array('langcode' ...
I have fought for some time with the error below:
Non-translatable field elements can only be changed when updating the original language.
I have "inherited" a site a few years ago and been updating it so it's D8 up-to-date (8.9.16).
When the user tries to save a change in language version of a page (on many but not all pages), she gets the aforementioned error message (even if not changing anyt ...
I used view translate(/admin/structure/views/view/my_view/translate) to translate a filter's label and saved. When I refreshed the view, it worked. Then I went to /admin/config/regional/translate/export page to export the same language's translation, including customized and non-customized, as .po file. But I couldn't find the translation I made in the file.
So how should I export the view's transla ...
I know I can install a new Drupal web site with single custom language using:
$ drush si standard \
--db-url='mysql://[db_user]:[db_pass]@localhost/[db_name]' \
--account-name=admin --account-pass=secret\
--site-name=Example \
--site-mail=noreply@example.com \
--locale=it
Similarly how can I pass multiple languages to locale key ?
--locale='it','uk','de'
doesn't work neither doe ...

First, I would like to say I am a total noob in Drupal and PHP but possess some knowledge on other web frameworks/languages).
Here is my path to the errors:
I used the UI to install Content Translation and Configuration Translation modules from the multilingual core (other 2 modules were already installed).
This did not work properly as it totally broke the website:
- aliases not respected (from "/co ...
I have been trying to translate menu items programmatically but upon saving it just adds the english field value to all my translations. Below is the code I am trying to execute:
if ($entity->hasTranslation($language->getId())) {
//For update
$entity->removeTranslation($language->getId());
}
try {
$entity->addTranslation($language->getId(), ['title' => ...