I have texts in different screens of my template that correspond to headers, links, etc. and that I need them to appear translated in my web page.
How can I enter words, text strings, etc. and put the translation in all the languages of my site from the admin?
Thank you.
in twig template you can translate value by this way :
{{ "Most Recent"|t }}
another example :
<a class="button" href="#">{{ "Show most recent item"|t }}</a>
more documentation here :
https://www.drupal.org/docs/8/api/translation-api/overview
Related
i know <h2>Hamburger</h2> are good, but how about this:
<div><h2>Food ยป Hamburger</h2></div>
or thats are ok for google seo?
The tag with an anchor link inside it will work same as a normal tag for Google SEO. Both the methods are Ok, but the problem that can occur is your readers may go away because you added a hyperlink in the Heading text of your webpage. So, it is not a good practice to use hyperlinks in tags or any tag.
We're having a weird problem in our AEM 6.3 application.
For some reason, the link to the contact-us page gets rendered with a space at its end, making it useless.
I'm trying to figure this out but I'm kinda new to sightly (I used to be working on CQ5).
To visualize it better, the configured link in the page properties is:
/content/app-name/hk/hk/info/contact-us
And the code in the HTML/sightly page is:
<a href="${inheritedPageProperties.linkToContactUsPage # extension='html'} ">
Contact Us
</a>
While what gets rendered in the actual page is:
<a href="/hk/hk/info/contact-us%20.html">
Contact Us
</a>
This happens only in the chinese pages of the site, I'm not sure if this is relevant or just a coincidence.
At first I thought the problem could be the blank space at the end of the href attribute, but shouldn't it result in "/hk/hk/info/contact-us.html%20" then? Also why would this problem affect only the chinese language pages and not all the other languages?
AFAICT you do have a space in the page properties link:
Please remove the space in your
<a href="${inheritedPageProperties.linkToContactUsPage # extension='html'} ">
like this
<a href="${inheritedPageProperties.linkToContactUsPage # extension='html'}">
I'm trying to render a Block's Field as Plain Text as I need it used as part of HTML, I've tried using |RAW however I read it was unstable + it didn't work haha!
This is my existing HTML minified
Read More
However I would like to make it more useable
Read More
This would mean that when a user modifies the DrupalBlock HEX code it would change the color of the box. However the issues is when it's printed on the page it's looking like this
<div data-quickedit-field-id="#" class="field field--name-field-color field--type-string field--label-hidden field--item quickedit-field">FFFFFF</div>
the only thing I would like printed is "FFFFFF" with no div's
-
Here is my question: How do I display my Field_color as plain text when it prints?
You can use |raw : {{ content.field_color|raw }}.
If you need more information please ask.
I suggest you do a dump or kint of your content.field_color variable. You might be able to get some more information on it and get the answer!
Anyway, we have something similar in our project and the way we do it is by using a .getString() method.
{% set image_align = content.field_image_align['#items'][0].getString() %}
<div class="{{ image_align }}">
Our field is a list of values so you'll have to look for another array item to call the .getString() method on.
I am trying to dynamically generate subjects in a mailTo link with a number using Razor from a html page. The Razor with the number is #Model.Number and I have been able to embed the number in the link, but not in the subject part of the link.
As in the code below, putting the Razor in the subject part of the link causes the email link to open with a subject that writes out #Model.Number literally. Putting it before the ?subject part does allow me to embed it. Is there a way to use the #model.Number razor in the subject of an email link?
#Email us
(Please note: my question differs from other similar questions as they do not attempt to embed Razor in the subject part of a link)
The dynamic value #Model.Number needs to be escaped with brackets to prevent getting parsed as a literal string, like this:
#Email us
You might try:
<a href='#("mailto:email#test.com?subject=Policy%20" + #Model.Number)'>#Email us</a>
or
<a href='#(String.Format("{0}{1}", "mailto:email#test.com?subject=Policy%20", #Model.Number)'>#Email us</a>
I am writing a 404 custom page and all is good, but I am using WPML and therefore I am localizing my strings.
This i part of my code:
<h4><?php _e('You still can\'t find anything?', 'kslang'); ?></h4>
<h5><?php _e('Well, then you probably should give us a wake up call...', 'kslang'); "\n"?></h5>
<h5><?php _e('but be aware who you\'re waking up!', 'kslang');?></h5>
<h5><?php _e('You\'re sure? Well, then...', 'kslang'); ?></h5>
<form>
<input type="button" value="<?php _e('Contact Us!', 'kslang'); ?>" onClick="window.location.href='http://example.com/contact-us-today'">
</form>
<h5><?php _e('or try the Site Map Below. You\'re also welcome to check out our related projects!', 'kslang'); ?></h5>
Now the issue is, that my
"window.location.href='http://example.com/contact-us-today'"
is not redirecting to the relative language.
I though I could simply wrap the href link in get text, like by button text and the rest of the strings.
this doesn't work, obviously the matter is more complicated.
Do I need to use a if/else statement?
Has anybody a idea how to redirect to the correct language?
(I tried to use _e with the idea to translate the href link in String translator, but this doesn't work with _e because inserting the php snippet breaks my site in this case)
Hope somebody can give a input...
to redirect to the appropriate language version using window.location.href, you need to include the language in your URL... i.e, for French, redirect to "http://www.example.com/fr/contact-us-today" (with "fr" after the domain). You can do this dynamically by detecting the current WPML language in PHP and echoing it as a JavaScript variable, like this:
//Get current WPML language
global $sitepress;
$language = $sitepress->get_current_language();
//Echo as JS variable
echo "<script>var lang = '".$language."';</script>"
Then, you can redirect like this:
window.location.href='http://www.example.com/'+lang+'/contact-us-today';
NOTE: This example assumes you are using language folders for your different languages. You will need to adjust accordingly if you are using subdomains or a language query parameter.