CodeIgniter Forums
What about a Country helper class. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=31)
+--- Thread: What about a Country helper class. (/showthread.php?tid=69008)



What about a Country helper class. - Geraldo_ - 09-26-2017

Just one thought,

Wouldn't it be helpful to have a country helper class? Just as we already have a language class.

Why?

Well for the following reasons:

Internationalization is not only a language issue and yes also a location issue.

I could stay, let's say in Germany while my preferred language is English. But this doesn't mean that I want to use decimal points instead of commas. The currency sign depends on the country, not the language. The validation rules for addresses (zipcodes, states etc..) depends on the country, not on the language.

I don't think it is a big effort to "copy" the language helper to a country helper. But the result would be great because we will be able to organize things better and more efficient.

I would like to receive critics, suggestions etc... on this issue.

Thanks,

Geraldo.


RE: What about a Country helper class. - PaulD - 09-27-2017

This idea possibly has some legs to it. I had not thought about this before but it could help. It could also config the time and date settings too possibly. Not sure it would work like the language helper, but similar I suppose. You could also use it to set the telephone number for that country too, or the delivery methods etc.

I am also guessing that you might create a file for one country, and then let others in their own countries create their own based on that template.

It is an interesting idea.

Paul.


RE: What about a Country helper class. - Tripex - 09-28-2017

It shouldn't be "Country"... it should be "Locale"... even a country can have different settings depending on which locale you adhere to.


RE: What about a Country helper class. - PaulD - 09-28-2017

That's a good point too.


RE: What about a Country helper class. - Geraldo_ - 09-29-2017

(09-28-2017, 12:46 AM)Tripex Wrote: It shouldn't be "Country"... it should be "Locale"... even a country can have different settings depending on which locale you adhere to.
I understand you, but yes what I was thinking of is a Country helper. Just for things like zipcode formats, phone numbers, currency and things like that. I have to validate addresses, but the validation rules depend on the country, I need to know if a country is using decimals in currency data, and if so how many decimals. I resolved this with database functionality, but I thought that it would be nice to have the same kind of solution as with the Language helper.

Other country-specific things could be licenses, discount options etc... So it is a little bit different from the "standard" Locales approach.


RE: What about a Country helper class. - jaynarayan - 10-04-2017

May be this is related
Link to number format helper function in ci4
This is  wrapper function for using  format function of php Internationalization Extention 


RE: What about a Country helper class. - Geraldo_ - 10-12-2017

(10-04-2017, 07:26 AM)jaynarayan Wrote: May be this is related
Link to number format helper function in ci4
This is  wrapper function for using  format function of php Internationalization Extention 

Thanks for your reply!