Questions tagged [i18n-l10n]

Use it in questions about adapting software to different languages, regional differences, and requirements of a target market (locale).

Filter by
Sorted by
Tagged with
33
votes
6answers
66k views

How do I translate strings in Twig templates?

I am working on a (my first) Drupal 8 project witch is a multilingual site. Drupal 8 really delivers in terms of native support for content translation. However, I have a few strings set directly in ...
30
votes
5answers
27k views

Best practice for language key for “und” in hook_form_alter

I'm modifying in a form in my custom module. Code looks like: function my_module_form_alter(&$form, &$form_state, $form_id) { if ($form_id == "someID") { $form['...
26
votes
5answers
10k views

Node translation vs. Entity (field) translation

I would like to know what you guys recommend for a multilanguage site. For example, consider the following case: A page and its content should be available in 3 languages (e.g. German, English, and ...
22
votes
5answers
10k views

Search only for the currently active language

How can I restrict the results from a default search in Drupal 7, to bring only the nodes that are in the current language? My website has a three language switcher; the user chooses what language he ...
19
votes
2answers
4k views

Why is it not recommended to change the default language?

I have a fresh installation of Drupal 8.2.5 and want to use it for mostly Spanish content, but keeping the admin interface in English. /admin/config/regional/language says, It is not recommended to ...
17
votes
4answers
8k views

Access denied occurs after translate menu link

I want to translate my menu, I have installed internationalization, variable and locale modules but on my menu items when I click on translate : An access Denied page is displayed : What am I doing ...
17
votes
1answer
2k views

What is the difference between “Language: Not specified” & “Language: Not applicable”?

What is the difference between Language: Not specified and Language: Not applicable in Drupal 8 In the context of multilinguality ? There was no such distinction in Drupal 7 (and 6, IIRC) and it ...
16
votes
1answer
12k views

How do I translate a view page title?

Is there a way to translate a view page title in Drupal 8? How can I achieve it, if it is possible?
15
votes
5answers
14k views

Import po-files using Drush

I have about 20 sites that have a common translation. I don't want to go into admin of each site each time the po-file is updated. Is it possible to import a po-file using Drush?
15
votes
2answers
2k views

How to set multiple domains for one language

I have a multilingual site with Drupal 7 using subdomains like en.example.com to detect the language. Everything works like expected, but I have a mobile version of the website witch I want to be ...
15
votes
3answers
2k views

Restrict editor user to only edit contents in one specific language

I'm trying to create a role for editors where one editor only has access to edit English contents and the other only has access to contents in another language. I've been researching for quite a ...
14
votes
5answers
5k views

How can I deploy user interface translation?

Strings that I translate at "User interface translation" /admin/config/regional/translate are not exportable by "Configuration management" /admin/config/development/configuration for me. Am I missing ...
14
votes
3answers
5k views

Is it always bad to pass a variable through t()?

I have a little helper function for my hook_schema: function _bbcmap_schema_asr_field($description) { return array( 'type' => 'int', 'unsigned' => TRUE, 'size' => 'small', // ...
14
votes
2answers
4k views

Multilingual content and single language admin interface

I want my site's content to be multi-lingual. I have a language switcher that can toggle between both the English and Spanish translations of a page. I want the administrative interface to always be ...
14
votes
4answers
3k views

How to make strings from templates translatable on all pages they appear?

I have some calls to t() in *.tpl.php files. For the sake of example, let's say I'm talking about products and product.tpl.php file. Strings in templates are not recognized until the first time they ...
12
votes
1answer
6k views

What is the difference between {{ |t}} and {% trans %}?

I notice that Drupal 8 support {% trans %} which, according to the Symfony documentation (The i18n Extension), adds gettext support to Twig. {{ |t }}, as far as I know, is the legacy way to add ...
12
votes
1answer
3k views

Export multilingual settings with features

I'm using features to export 10 content types, but I don't get the multilingual settings. My question is, whether this is even possible, maybe with strongarm or I'm stuck having to change those ...
12
votes
3answers
1k views

Move Multi-lingual Content with Migrate Module

I've got a single MySQL table with mixed english/french content in each row. I'm trying to figure how to migrate this into a proper i18n configured Drupal site. I can get Migrate to import the ...
12
votes
0answers
2k views

How do I translate theme settings?

How do you translate custom theme settings in Drupal 8? I use hook_form_system_theme_settings_alter to add custom settings to a theme. One setting is the text string (e.g. 'Menu') to display beside ...
11
votes
5answers
2k views

Should I use t() in a hook_menu's description?

I have always used t() for hook_menus title and description like this: $items['some-path'] = array( 'title' => t('My Page Title'), 'description' => t('This is a description about what ...
11
votes
3answers
10k views

Retrieve translated taxonomy term in current language programatically

How do I retrieve a specified taxonomy term translated (if translation exists for this term) from the current language context programmatically with D8?
11
votes
1answer
5k views

How do I get Views content items in “my language” but fall back to “default” if the content isn't translated?

This is probably very easy but endless searching has proved fruitless - there's lots of UI changes between the D7 and D8 versions of these modules it seems. What I want to do is create a blog in two ...
11
votes
5answers
5k views

How to get the taxonomy translated in URLs?

I have a bilingual site with localized taxonomy terms used as categories. I would like to achieve this: http://www.mysite.com/about/pageinenglish http://www.mysite.com/apropos/pageinfrench (A ...
10
votes
5answers
19k views

How to get the translated term name by tid?

I'm looking for a working method to get the translated term name by tid. The following code returns the original term name but not the translation. global $language; $lang_name = $language->...
10
votes
2answers
11k views

Passing variables that contain HTML through the t() function - ! placeholder has been removed

In Drupal 8, it appears that using the ! (exclamation mark) placeholder with the t() function has been removed. I have a variable that contains HTML: <span class="fullname_wrapper"><span ...
10
votes
8answers
15k views

How to get the path to the translated node?

I've set up a multilanguage site in Drupal 7. In a template I need to add a link to a specific content node. This node has translations and path aliases like so: node/42 = pathalias_de (german ...
10
votes
2answers
8k views

Best practice: $this->t() versus t()

I'm looking for a best practice: should contributed modules use $this->t() or t()?
10
votes
2answers
3k views

Always keep admin UI in English when translating content

How can I prevent the admin UI switching to a foreign language every time I translate a piece of content? i.e. I'm editing a Menu item and I've clicked the Translate tab. I click 'Add' in the German ...
10
votes
3answers
8k views

How do I get translated strings into Drupal.locale.strings?

So I'm trying to use the Drupal.t() function in some of my custom Javascript code (in my theme). How do I get the strings I need populated in the Drupal.locale.strings object? I see some strings in ...
9
votes
3answers
9k views

How to create a multilingual node programmatically?

In the last days I tried to migrate a multilingual CSV file to Drupal 8 without success, so finally I decided to use a Batch Process to accomplish the task. At this moment I have the batch process ...
9
votes
2answers
9k views

How do I get the translated title of a node?

I have a content type available in FR and in EN. In hook_node_presave(), I would like to concatenate the French title and the English title in another field. (This is an "helper field" which contains ...
9
votes
1answer
1k views

Why would the body field's language not save as the same language as the node?

I am having a problem where the user is creating new nodes and entering body text, but setting the nodes to "language neutral" for the language. Yet when it saves the node the body field's language ...
8
votes
2answers
12k views

How do I get a field translated in Drupal 8

I have a multilingual site in Drupal 8, and several node, some translated and others not. As I can programmatically get the translated field or by default they give it back from the original language. ...
8
votes
3answers
6k views

How to change the behaviour or display of the language switcher?

On translated pages the language switcher shows links to translated languages, but for untranslated languages there is no link, but the name of the language without a link. In the case, that there is ...
8
votes
1answer
11k views

Block body translation for Full HTML content

After block creation and put HTML content in body field I can't translate this content because of: The string blocks:block:1:body for textgroup blocks is not allowed for translation because of ...
8
votes
2answers
10k views

Accessing $language inside node content in drupal 7

Normally I would use $language to get the active language on my drupal 7 page. Now I'm doing some changes to a node content (set to PHP code) and I can't seem to get any variables working? I badly ...
8
votes
4answers
6k views

How to: Multilanguage site, but single language backend?

I have almost completed my first Drupal 7 multilanguage test site. As long as I'm not logged in, I can browse through all pages and switch languages. When logged in, my first issue was that the ...
8
votes
2answers
992 views

How to avoid Drupal redirecting my multilingual Views pages?

I've got a Views page in a multilingual website where I need a different url for each language, ie: es: mysite/apartamentos. en: mysite/appartments. fr: mysite/appartements. ru: mysite/arendu. I ...
8
votes
1answer
5k views

create multilingual node programmatically

i'm trying to create a multilingual node using a php script. I'm doing this: $node = new stdClass(); $node->title = "Test ".mktime(); $node->type = "job"; $node->language = 'de'; // Or ...
8
votes
2answers
3k views

Programmatically add node translation

I am using i18n module. How can I programmatically create node translation?
8
votes
1answer
237 views

How to translate plural strings with Drush?

If we want to translate a plural string in Drupal we can use the format_plural() function. If you are programming drush commands you can use the dt() function to translate strings, but if you want to ...
8
votes
2answers
9k views

How do I translate the Webform module form?

I really see no way of translating the Webform module. Is anyone else facing this issue? I know it is possible with locale (for the same node), or creating another node, but I really want to use the ...
8
votes
2answers
2k views

Change drush language

Suddenly my drush has switched language and displays error messages in my native language, which is unfortunately not convenient if one tries to search for solutions on these errors. Do you know how ...
8
votes
4answers
5k views

Views 3, contextual filter on language - allow for multiple languages

So for this site I'm building I need to be able to do the following. When user views the site in English show all English articles When the user views the site in Dutch, show all Dutch articles - but ...
8
votes
1answer
4k views

Do not translate the admin area / How can I set the language of the admin area to English?

I am building a multilingual site with 3 languages. Lets say English, Italian and German. English is the default language. Is it possible to leave the admin area untranslatable, even I am currently ...
8
votes
1answer
424 views

Is it possible to migrate data into multiple translations of entities?

I'm running a multilingual migration of events (which are stored as nodes) that have keywords on them where there are keywords (stored as terms). The keywords should be stored in a multilingual tags ...
7
votes
4answers
27k views

Get current language in template

In Drupal 7 the current language is a global variable we can access with global $language; $langcode = $language->language; I want to know how can we access the current language in a Twig file ...
7
votes
5answers
12k views

How to remove language indicator in content region?

It took me a while to figure out how to remove the language switches from the bottom of each page. Eventually the switch was in a somewhat logical location (Multilanguage settings > Article options). (...
7
votes
3answers
9k views

How can I get my module to see the current language my user is using?

When I use Node::load(10)->toArray() I see that my module thinks that the current language is English. I have the language key (fr) in the url and when I place \Drupal::languageManager()->...
7
votes
5answers
4k views

Proper way to get the base path when including an image from a module?

When using just drupal_get_path() to include an image from a module directory, this produces non-existent urls when using language prefixes. I've seen a couple of modules prepend base_path() to deal ...

1
2 3 4 5
38