I currently have the following markup in a Go template:
{{ .PublishedAt.Format " Jan 02, 2006" }}
I'd like to display it using this format, but in another language. Is this a feature built-in in Go? If not, what is the best practice to achieve this?
Related
I am working in my Ionic 4 app and I have added multilingual in my app. In English, the text is coming properly but in the Arabic, Numbers are coming first and then Arabic words are coming.
This is my tab2.page.html:
<p class="myp11">
{{ challengesuser.target }} {{ 'STEPS_IN' | translate }} <span>{{ challengesuser.duration }}</span>
</p>
In this, I am showing the value coming from the server and Some parameters which is translated according to the language selected.
But the problem is that, in Arabic, numbers are coming first:
In English, it is coming correct like this :
7000 steps in 30 days
Any help is much appreciated.
In TYPO3 I am using the News Extension to create an Event. In my List view I am using the following code snippet to show the End Time of the Event.
<f:format.date format=" - %H:%M Uhr">{newsItem.eventEnd}</f:format.date>
Which results in " - 20:00 Uhr" (German Language, hence the "Uhr").
I want a Format that switches that time to " - 08:00 PM" for the English translation, I am assuming that is not possible in Fluid since my searches have no result. Is there any workaround?
You can put your format into a locallang file. There it's possible to change the format related to the language.
<f:format.date format="{f:translate(key:'dateFormat')}">{newsItem.eventEnd}</f:format.date>
The date format viewhelper uses the same format as the default PHP date and strftime functions, so anything you can use %I:%M %p to get 08:00 PM. See http://php.net/manual/en/function.date.php and http://php.net/strftime for more about this.
I need to change the mailchimp locale *|DATE:M y|*. This gives Apr 2013 and I want Abr 2013 (Portuguese format). Is there any way to do this?
Thanks!
Have you tried wrapping the date with a translate merge tag?
*|TRANSLATE:PT|* *|DATE:M y|*
http://blog.mailchimp.com/automatically-translate-your-emails-to-over-30-languages/
The list of language codes can be found here:
http://kb.mailchimp.com/article/is-it-possible-to-translate-content-in-multiple-languages
But the Portugese options are:
Portuguese (Brazil) = pt
Portuguese (Portugal) = pt_PT
There you go
setlocale(LC_ALL, 'pt_PT');
echo strftime("%b %d %Y");
this will output
Abr 18 2013
To format dates in other languages, you need to use the setlocale() and strftime() functions
I have wikimedia tags in a text file. I need to get rid of these tags from starting to ending even when nesting. I'm using Perl.
I'm facing a difficulty in nested tags. I'll give two examples of these tags that I could not to remove.
Example 1:
{{ text
text
text {{ text
text}}
text }}
Example 2:
instead of "{{" in example 1, we have the tags "]]".
[[ text
text [[ text
text]]
text ]]
I hope someone to pinpoint me to solve this issue
Have you looked at Can I use Perl regular expressions to match balanced text?
s/{{|}}//g;
will erase the {{ or }}
Are there any filters or something like that in twig template engine to format money or numbers?
The number_format filter has been included in the Twig core since the end of December 2011. The relevant commit is here.
Usage: number_format(decimals, decimalSeparator, thousandSeparator)
{{ total|number_format(2) }}
{{ total|number_format(0, '.') }}
{{ total|number_format(2, '.', ',') }}
Read more about it in the docs
The Twig Extensions library contains a number of useful extensions for Twig. With the release of version 1.2.0, a localizedcurrency filter has been added to the Intl extension. As the name suggests, this filter will format a number based on the current locale. It uses PHP's NumberFormatter class to do so.
Usage
This filter is very easy to use. The only required argument for the filter is the 3-letter ISO 4217 currency code. For instance, to display an amount of 27.99 in Euros, use the following line of code:
{{ price|localizedcurrency('EUR') }}
This will display different results depending on the locale:
€27.99 if the locale is set to en
27,99 € if the locale is set to fr
€ 27,99 if the locale is set to nl
Installation / setting the locale
Installation instructions for the Intl extension can be found in this seperate answer.
If you are using an older version of twig and you don't want to install any extensions you can use the format filter like this:
{{ "%.2f"|format(total) }}
Not very nice, but it works.
Basically format works like PHP's sprintf function
Use the format_currency
From version 2.12 format_currency filter was added. More information in the official documentation https://twig.symfony.com/doc/2.x/filters/format_currency.html