Documentation
¶
Overview ¶
Package arbfile implements reading and writing of Flutter ARB (Application Resource Bundle) files.
ARB files are JSON files with a specific structure:
- "@@locale" holds the BCP-47 language code (e.g. "en", "ru").
- Keys starting with "@" (other than "@@locale") are metadata entries (e.g. "@greeting") and are preserved verbatim — never translated.
- All other string values are translatable.
File naming convention: app_LANG.arb (e.g. app_en.arb, app_ru.arb) stored in a single directory (e.g. lib/l10n/).
Round-trip fidelity: key order from the source file is preserved, and metadata keys immediately follow their corresponding translatable key.
Index ¶
- func SyncKeys(src, target *File)
- type File
- func (f *File) Get(key string) (string, bool)
- func (f *File) Keys() []string
- func (f *File) Locale() string
- func (f *File) Marshal() ([]byte, error)
- func (f *File) Set(key, value string) bool
- func (f *File) SourceValues() map[string]string
- func (f *File) Stats() (int, int, float64)
- func (f *File) UntranslatedKeys() []string
- func (f *File) WriteFile(path string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type File ¶
type File struct {
// contains filtered or unexported fields
}
File represents a parsed ARB file.
func NewTranslationFile ¶
NewTranslationFile creates a new File for targetLocale mirroring src's structure but with all translatable values cleared.
func (*File) Marshal ¶
Marshal serialises the ARB file to JSON with 2-space indentation. The @@locale key is always written first.
func (*File) Set ¶
Set sets the value of an existing translatable key. Returns true on success, false if the key is not found or is metadata.
func (*File) SourceValues ¶
SourceValues returns a map of key → value for use as translation source.
func (*File) UntranslatedKeys ¶
UntranslatedKeys returns translatable keys whose value is empty.