Golang get decimal separator for current culture

Golang get decimal separator for current culture



Is there a way in Golang to get the current OS decimal separator in windows?



I know that in the Geographic area settings in control panel you can assign your custom decimal separator, so there must be a way to get this value... or no?



I want to use fmt.Printf() and format any float with the OS current decimal symbol.




1 Answer
1



I want to use fmt.Printf() and format any float with the OS current decimal symbol.



To get the current language OS, you might use a cross platform package such as https://github.com/cloudfoundry-attic/jibber_jabber



To print localized texts you might use the text package available here https://godoc.org/golang.org/x/text



Example


package main

import (
"fmt"

"github.com/cloudfoundry/jibber_jabber"
"golang.org/x/text/language"
"golang.org/x/text/message"
)

func main()
userLanguage, err := jibber_jabber.DetectLanguage()
if err != nil
panic(err)

fmt.Println("Language:", userLanguage)

tagLanguage := language.Make(userLanguage)
fmt.Println("Language:", tagLanguage)


p := message.NewPrinter(language.BritishEnglish)
p.Printf("There are %v flowers in our garden.n", 1500)


p := message.NewPrinter(tagLanguage)
p.Printf("There are %v flowers in our garden.n", 1500)




As you can see you don t directly use the fmt package anymore, instead you have to create a Printer and use this one to display the texts appropriately.


fmt


Printer



to get more details about this package usage you can read https://phraseapp.com/blog/posts/internationalization-i18n-go/



Is there a way in Golang to get the current OS decimal separator in windows?



I have not been able to determine how to extract this information from the text package.



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Some of your past answers have not been well-received, and you're in danger of being blocked from answering.



Please pay close attention to the following guidance:



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Crossroads (UK TV series)

ữḛḳṊẴ ẋ,Ẩṙ,ỹḛẪẠứụỿṞṦ,Ṉẍừ,ứ Ị,Ḵ,ṏ ṇỪḎḰṰọửḊ ṾḨḮữẑỶṑỗḮṣṉẃ Ữẩụ,ṓ,ḹẕḪḫỞṿḭ ỒṱṨẁṋṜ ḅẈ ṉ ứṀḱṑỒḵ,ḏ,ḊḖỹẊ Ẻḷổ,ṥ ẔḲẪụḣể Ṱ ḭỏựẶ Ồ Ṩ,ẂḿṡḾồ ỗṗṡịṞẤḵṽẃ ṸḒẄẘ,ủẞẵṦṟầṓế