booleanbites / houzi-support

Support forum repo for issues & bugs reported for Houzi Flutter App.
4 stars 0 forks source link

Price format translated #93

Closed quitriz closed 9 months ago

quitriz commented 9 months ago

Hi,

where do i go to edit the short price symbol to the translated one please? like $2.3B to $2.3Ri ? the "B" i need to change ..

thanks

AdilSoomro commented 9 months ago

You can use the compact price hook from hooks_v2.dart

This hook will send you the full price, that you can process and return your own price string with your desired formatting.

checkout the doc: https://houzi-docs.booleanbites.com/hooks-widgets/price_formatter_customization

quitriz commented 9 months ago

You can use the compact price hook from hooks_v2.dart

This hook will send you the full price, that you can process and return your own price string with your desired formatting.

checkout the doc: https://houzi-docs.booleanbites.com/hooks-widgets/price_formatter_customization

I just need to turn that B into vietnamese, i am good to use default one and I am not flutterer ..

thanks

Hassan6197 commented 9 months ago

Hello @quitriz We’re using native number formatter for this. We’re showing whatever denomination it returns. If the number formatter in your language shows your native denomination for B or K or M, then you can try using the localized number formatter. Otherwise from the hooks, you can call existing compact number method and replace B or K or M in your language, with string replace method.

quitriz commented 9 months ago

hi Hassan,

yes, where or which file do i need to edit to change that B/M/K symbol etc into my localized symbol?, I edited in houzez but not in the app, i can "grep" out the world Billion in houze but in app there is just. "B" so its hard for me to locate where its located to change it into the localized symbol.

thank you

Hassan6197 commented 9 months ago

Go to packages/houzi_package/lib/files/generic_methods/utility_methods.dart and look for makePriceCompact() method. The billion word isn't written anywhere in the app. We pass the full number to a NumberFormatter class by flutter, which makes it compact and return it in shortened form.

quitriz commented 9 months ago

makePriceCompact

Hi Hassan,

I did look at that, but I still dont' find the symbol "B or K or M" to be replace for example after the compact price.

1 000 000 000 it's 1B and i wanted to change that "B" into "tỷ" = 1tỷ, and the 1M = 1triệu, 1K = 1nghìn , that's all, i don't to do anything with the number, and somehow i can't find it in there to change. can you help ?

thanks

AdilSoomro commented 9 months ago

Hi @quitriz , if you look into the class that Hassan pointed out, utility_methods.dartand the function makePriceCompact(), it is using NumberFormat class, which is a flutter core library class that takes the whole number and provide us with minified version of the number. By default its locale is set it to US. You can change its locale to your country and see if it supports your locale out of box or not. Following example uses US locale and formats the price.

compactPrice = NumberFormat.compact(locale: "en_US").format(priceDouble);

We don't do the calculation and append B or K or M and make the number compact, rather we simply pass the full number and get the compact number from the flutter class (NumberFormat) itself. As hardcoding such things would create lot of problems.

quitriz commented 9 months ago

Hi @quitriz , if you look into the class that Hassan pointed out, utility_methods.dartand the function makePriceCompact(), it is using NumberFormat class, which is a flutter core library class that takes the whole number and provide us with minified version of the number. By default its locale is set it to US. You can change its locale to your country and see if it supports your locale out of box or not. Following example uses US locale and formats the price.

compactPrice = NumberFormat.compact(locale: "en_US").format(priceDouble);

We don't do the calculation and append B or K or M and make the number compact, rather we simply pass the full number and get the compact number from the flutter class (NumberFormat) itself. As hardcoding such things would create lot of problems.

Hi, Ah, thank you, that explained clear enough. I didn't know that, always thought you guy created a separated function to do the number.

P.S.: thank you for pointing that out, I got it working now. thanks ..