How to display currencies and languages depending on the country? - localization

Can I display currencies and languages depending on the country in prestashop. If yes, how?

Yes you can, if you know how to code.
But in which context ? what language ? php ? js ? in your tpl ?
Be more explicit.
For example, you can find the language with this php line :
$this->context->language->id;

Related

Symfony 5 : translate Arabic numbers to Modern numbers

I use Symfony 5, and I checked Arabic like the default language of the website.
but when I write a number on the database and get it, the Symfony translate it automatically to Arabic numbers ( from [1,2,3,4,5,6,7,8,9] to [١,٢,٣,٤,٥,٦,٧,٨,٩] ).
is there any solution to use modern numbers in place of Arabic numbers ?
After a lot of searches and analyzing I found that issue come from the NumberType input, so I changed to the TextType input

How can I translate my webpage to another language (Can't use google translator or any else)

Basically i want a translator that translates my webpage to a specific language (word meanings are project specific). Now for that language words and corresponding word meaning should be made manually. i mean , something like a dictionary should be there. Because the words / texts that are need to be converted have specific meanings based on my project. So what is the best method / concept / approach to do this ?

Standard for specifying Locale in the URL

Is there a standard for specifying the Locale (Country+Language) in the URL. I have seen:
example.com/fr-fr/page
example.com/page?locale=fr-fr
fr.example.com/page
example.com/page^fr_fr
I'm not sure if there's a standard in place, this is usually free of choice and depending on the project scope.
I think it matters more to put the language first because many countries use the same language. So you specify the language first and then the 'region' to narrow down.
Answering the following questions can help choosing the format:
do you need to support multi-languages per country (ex. dutch in belgium: nl/be & dutch in the Netherlands: nl/nl) ? This is usually when you need to track analytics per country/language.
do you just need to support the main languages (en, de, fr, es, pt, jp,...) and not care about the regions ?
does SEO matter ?
what looks better visually ?
I usually go by www.url.com/{LANG}/{COUNTRY}/ or www.url.com/{LANG}-{COUNTRY}/

Determine if a string is English

Is there a library where I can simple call a method on a string to find out if it is non-English? I'm trying to only save English strings and the incoming stream of strings has plenty of non-English in them.
You can try to use linguo.
"your string".lang
# will return "en" for english strings
Disclaimer: I'm the creator of this gem.
You can use GoogleTranslate API with the RailsBridge for it - http://code.google.com/apis/gdata/articles/gdata_on_rails.html
Not that I'm aware... but you could get this list into an array (http://www.langmaker.com/wordlist/basiclex.htm) and then match the string's words against it... Decide on some percentage as good, and go from there.
You could even use bayesian algorithm here to mark those words as "good" and learn from there, but that might be overkill.

Best practice to represent Money (value + currency) in Grails

I'm not much familiar to Java Currency type, and how it being used in Grails. Though, I'm yet to use it, I saw a tag <g:currencySelect> to use in the views. So, how do I represent it in the domain class.
class Money {
BigDecimal value
Currency currency
....
}
or is there a better sol, which compares diff money objects, format according to the locale ( ',' in EU for separator etc)
thanks in advance.
Babu.
You should use BigDecimal. Groovy and Grails has excellent native support for it as a datatype on GORM domain classes as well. For reasoning behind using it, see here
What is the best data type to use for money in java app?
You might want to take a look a the Currencies plugin. It provides a Money class for holding monetary amounts of differing currencies. They can be embedded into domain classes like so:
class CustomerTransaction {
Date date = new Date()
Money amount
static embedded = ['money']
}
Use the JScience library. It's just a shame it's not in a Maven repo yet, and doesn't have a Groovy wrapper to make it Groovier (TM).
If you want to have also live exchage rates updates then following plugin could help https://grails.org/ExchangeRates+Plugin all rates are pulled from Yahoo Finance.
since the original answer seems to be outdated, you might want to take a look at the money-plugin which is fresh and currently maintained.

Resources