I have I site in Drupal 8 and a content type named "Ενηλίκοι".
The content's type title "Ενήλικοι" is shown on the front end. How can I tranaslate "Ενήλικοι" to "Adults" when I am viewing the site on the english language?
Edit: I noticed that there is an option for translation the content type title, but when I use it I get the error:
The configuration objects have different language codes so they cannot
be translated:
node.type.drastiriotites_enilikoi: el
core.base_field_override.node.drastiriotites_enilikoi.title: en
Can somenone help me?
You can use Drupal.t function for such purpose.
Related
In odoo 15 I have created a custom layout template for an invoice report (PDF). This template contains some texts in German language. Where do I have to specify any translation of these texts so they are considered if the invoice is printed in e.g. English?
Activate debug mode.
You can find it in settings > translations > Transleted terms, and you search for your germans terms for translate them one by one.
You can set your template manually, settings > Technical > Email templates
and now you can edit the template. But this is a non-dynamic solution.
More dynamic way :
Use .po,.pot files in your custom modules. if you have computed strings in your template use the function "_" before.
Ex :
my_str = _("Hello, how are you")
afterwards, edit the '.po' file
Look at the documentation here:
https://www.odoo.com/documentation/16.0/developer/howtos/translations.html
Regards,
I'd like to translate each node title as a string (using i18n). I'm trying this function in my theme template:
function theme_process_page(&$variables) {
$variables['title'] = t($variables['title']);
}
Yet when I refresh strings, none of my node titles are on the list. Is there something I'm missing?
And to clarify the function name is using my theme name, not the word "theme".
Title is my usual solution for this (I use Entity Translation, it works fine with Title module).
This module replaces node titles by a regular translatable text field. You can choose wich content type titles must be replaced (on the "Manage Field" forms, you'll find a "replace" link in the title row). Pretty useful.
Good luck
You should never use t() to translate user-supplied or variable strings. See the documentation on the function.
That said, there are some solutions, one is to use the built-in language support for entity fields. Following that you should be able to do something like this in a field hook (in a module, not in your template):
$langcode = $field_info['translatable'] ? $content_langcode : LANGUAGE_NONE;
$entity->{$field_name}[$langcode][0]['value'] = t("Salut!");
In a Drupal project, i have a basic weborm. As soon as the user submits one, an email is send with all the things he just wrote.
Example:
Imp_First_Name:%value[firstname]
Imp_Last_Name:%value[lastname]
Imp_City:%value[lastname]
Imp_Country:%value[country]
Imp_Email:%value[email]
Imp_Subject:%value[subject]
I have a problem on this line:
Imp_Subject:%value[subject]
Subject contains what the user have selected within a select list. My problem is when the website is set to chinese, all is written in chinese obviously but i don't want the chinese version to be sent. I need the english one.
For example :
In my webform, the user has the choice between 3 countries:
Afghanistan|阿富汗
Afrique du Sud|南非
Albanie|阿尔巴尼亚
I need the country name in latin alphabet ! How can i manage to do this?
thanks in advance for your help
It's a tricky one...
There is substitution and also two possible template layers. One comes from webform and second comes from mailsystem / mail handler module.
I'm assuming that the substitution is done before the template layer so the t() function should be applied either within a hook on that level or within the proper template file.
Debugging with XDebug would really help to solve the issue.
I'm using Node Comments module and I get a strange error in Status Report:
Node Comments
Content type Answer has Drupal core comment comment type, but is a comment type itself for the following content types: Forum topic
However, in the content type settings of 'Answer', this setting is disabled:
http://dl.dropbox.com/u/72686/CommentSettings.png
thanks
In the description under 'Node Type for Comments': "Important: Every content type which is a comment type should have itself as comment type. Also every comment node type should have at least 1 another content type using it."
What you show is the default setting. It is still possible that one of the comment nodes has a comment somewhere. You can use SQL to investigate.
To be sure that no one can create comments, you need to remove the option in the node create form. However, this wont solve the problem with the already created comment.
I have CCK and Views module installed. For the sake of this question scope, I'll call the content type as Project. Projects have many Members.
Project nodes are accessible through /project/project-name. I want to be able to display list of members through path /project/project-name/members.
Is there any way to do this?
Currently I have a views setup for page display on path /project/%/members, and have the argument taken from the url. I realize I can't use "Node ID from URL" option directly since it's node name instead of node id. Therefore I tried to enable "PHP Code" argument. But the problem is, Drupal Views always assume that the parameter is "project-name" and therefore ignored my php code argument setting. Anyone knows how I might be able to do this?
Thanks
Yes, you can actually use the "Node ID from URL" option, and you should.
Use the path or pathauto module to generate human-readable URLs for your projects in the form project/project-name. This will create a human-readable alias for the node, but the underlying Drupal system path is still node/nid.
Views can still use the "Node ID from URL" as an argument (or Contextual filter, as they are known in Drupal 7) even with human-readable aliases for those ugly paths.
If the project's name is the node title you can get what you want pretty easily.
You can pass the node title as argument instead of the nid, but the result will be the same. You get some options to use lowercase, transform - to space ect, as what you can do in a url is limited compared to a node title.
The rest of the view would be the same, as the solution using node nids in the url.
You need to create path aliases for /project/project-NID/members to /project/project-Name/members
I asked this exact question a month ago. :)
drupal link to view dependent on argument