Translating
Table of contents
Introduction
ezBookkeeping supports multiple languages and localization settings, with separate language files for the frontend and backend. The frontend language files are located in /src/locales/
, and the backend language files are in /pkg/locales/
. All language files should be named using language tags (either a single language subtag or a language subtag with a script subtag, such as en
, fr
, zh-Hans
or zh-Hant
).
For more information about language tags, please refer to RFC5646. All available language tags can be found in IANA registry language-subtag-registry.
Add new language for frontend
- Copy
/src/locales/en.json
and create a new file named with the language tag - Add a key-value pair to the
allLanguages
object in/src/locales/index.js
. The key should be the language tag, thename
field in the value object should be the language name in English, thedisplayName
field should be the language name in that language, and thecontent
field should be the imported new language object. In addition, to be compatible with some third-party services that don’t support language tags in thelanguage-script
format, a language tag in thelanguage-region
format needs to be set in thealternativeLanguageTag
field (e.g.zh-CN
) - Translate each text item
Add new language for backend
- Copy
/pkg/locales/en.go
and create a new file named with the language tag - Add a key-value pair to the
AllLanguages
map in/pkg/locales/all_locales.go
. The key should be the language tag, and theContent
field in the value object should be the new language object - Translate each text item
Internationalization
ezBookkeeping allows users to change multiple regional settings, such as date, time, numeral, and currency formats. If the user does not change these settings, the default values configured in the language files will be used. These default values are in the default
object of the language file.
Here are all the settings that require default values and their descriptions:
Item | All Available Options | Description |
---|---|---|
currency | allCurrencies in /src/consts/currency.js | The default currency |
firstDayOfWeek | allWeekDays in /src/consts/datetime.js | The default first day of the week |
longDateFormat | allLongDateFormat in /src/consts/datetime.js | The default long date format |
shortDateFormat | allShortDateFormat in /src/consts/datetime.js | The default short date format |
longTimeFormat | allLongTimeFormat in /src/consts/datetime.js | The default long time format |
shortTimeFormat | allShortTimeFormat in /src/consts/datetime.js | The default short time format |
decimalSeparator | allDecimalSeparator in /src/consts/numeral.js | The default decimal separator |
digitGroupingSymbol | allDigitGroupingSymbol in /src/consts/numeral.js | The default digit grouping symbol |
digitGrouping | allDigitGroupingType in /src/consts/numeral.js | The default digit grouping type |
currencyDisplayType | allCurrencyDisplayType in /src/consts/currency.js | The default currency display type |
In addition, the format
object in the language files contains options for date and time formats for each language. These formats can be configured according to the Moment.js documentation. The specific usage scenarios for these formats are as follows:
Item | Usage Scenarios |
---|---|
longDate | Multiple scenarios |
shortDate | Multiple scenarios |
longYear | Used in the overview data on the homepage |
shortYear | Used in the time filters on the transaction and statistics analysis pages |
longYearMonth | Used when displaying months in the transaction list |
shortYearMonth | Used in the time filters on the transaction and statistics analysis pages |
longMonthDay | Used in the overview data on the homepage |
shortMonthDay | Used in the time filters on the transaction and statistics analysis pages. It will be displayed next to the shortDate and should have a similar format. |
longTime | Multiple scenarios |
shortTime | Multiple scenarios |