chrneumann / g5t Goto Github PK
View Code? Open in Web Editor NEWGettext for Go, stripped down to the bare metal
License: BSD 3-Clause "New" or "Revised" License
Gettext for Go, stripped down to the bare metal
License: BSD 3-Clause "New" or "Revised" License
Internationalization and localization support. This module is a <<< subset >>> and rewrite of the Python gettext module in the Go language. The main difference between this module and the Python gettext module is that this one only uses unicode. This approach reduces the code size significantly. This module contains only ---- SIX ---- exported functions: Parse() // This is the ".mo" file parser and is overridable LoadLang() // This function loads a translation into Catalog struct Catalog.String() // This function returns a translated string Catalog.StringN() // This function returns a translated string in plural form Catalog.StringPartial() // This returns a plain string->string function for calling String Catalog.StringNPartial() // This returns a plain string->string function for calling StringN Usage (short): 1) To use this package in your application, write this line (it's go-installable): import "github.com/GerardNL/g5t" 2) Run for each ".go" file: xgettext -o messages.po -C -kG -kGN:1,2 yourprogramfile.go 3) If you want to place the translation files to a sub directory of your application, make a directory called "translations" (for example) To locate your translations place this function in your app: lang := gt.LoadLang("your_app", "directory_to_transl_files", "language", Parser) 4) In your application define functions (for singualar and plural): G := lang.StringPartial() GN := lang.StringNPartial() 5) Code the rest of your program. When you want a string that needs to be translated, write G("string to translate") etc. 6) Translate "messages.po" with a text editor to a specific language and save the file to "yourdomain.po". Then run msgfmt yourdomain.po Msgfmt creates "yourdomain.mo". Copy this file to the language translation directory (in Debian this is "/usr/share/locale/") 7) That's it. TODO: - Bugfixing. - Make it work on different operating systems. - Listen to input from others.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.