flutter_translation_sheet library

Classes

AppStrings
CliConfig
EnvConfig
Model to represent the configuration (trconfig.yaml).
ExtractStringCommand
Command logic for fts extract
FetchCommand
Command logic for fts fetch
InitCommand
Command logic for fts init
LangInfo
Class to extend Locale information with nativeName, englishName and key,
LocaleSelectionCommand
Command logic for fts locales
ReCase
An instance of text to be re-cased.
RunCommand
Command logic for fts run
SheetParser
UpgradeCommand
Command logic for fts upgrade
VarsCap

Enums

YamlStyle
Original package "json2yaml" by alexei-sintotski

Extensions

StringReCase on String

Constants

defaultConfigEnvPath → const String
kGoogleLanguages → const Map<String, String>
kHasAssetsKey → const String
kHasAssetsReplace → const String
kLangIsoAllowed → const List<String>
google codes.
kLangMap → const Map<String, Map<String, String>>
Glossary of the available locales with their native names and english names.
kNoAssetsKey → const String
kNoAssetsReplace → const String
kRef → const String
kUnwrap → const String

Properties

argsJoiner String
getter/setter pair
changedWords List<String>
List of modified words captured based on reservedWords.
final
config EnvConfig
getter/setter pair
configPath String
getter/setter pair
configProjectDir String
Speculates the Flutter project dir based on the configPath location.
no setter
entryDataHasVars bool
flag that tells us if we have vars to parse or not.
getter/setter pair
extractAllowedExtensions String
getter/setter pair
extractCleanResults bool
getter/setter pair
extractExcludePaths String
getter/setter pair
extractPermissive bool
getter/setter pair
extractStringOutputFile String
getter/setter pair
invalidCharsRegExp RegExp
final
libFolder String
getter/setter pair
metaFallbackProperties Map<String, dynamic>
getter/setter pair
metaProperties Map<String, dynamic>
getter/setter pair
onlyDigitRegExp RegExp
final
pubSpecMap Map
getter/setter pair
pubSpecStr String
getter/setter pair
reservedWords List<String>
List of Dart reserved words to be escaped in the TKeys output.
final
sheet SheetParser
final
varMatching RegExp
final
varReplacer RegExp
final
varsByKeys Map<String, dynamic>
getter/setter pair

Functions

addAssetsToPubSpec() → void
Adds the json files directory. to pubspec.yaml assets.
addConfigOption(ArgParser argParser) → void
Adds the config argument argParser
addLocalesInPlist() → void
Keeps the iOS Info.plist locales in sync with your trconfig.yaml locales. Only runs on MacOs, as some Linux distributions have a different plutil version that throws with the arguments.
buildArb(Map<String, Map<String, String>> map) → void
Creates the {locale}.arb files to be used by intl package or similar. when config.yaml has intl:enabled:true. Takes the map with all the translations to generates the files.
buildCanoMap(Map<String, dynamic> map) KeyMap
buildLocalYamlMap() JsonMap
buildPath(List<String> path) String
Shortcut utility to join paths properly in different environments.
buildVarsInMap(Map<String, String> map) → void
captureVars(String str) VarsCap
checkUpdate([bool fromCommand = true]) Future<void>
Command to run from fts upgrade or automatically after all executions. Checks if there's a new version available on pub.dev and allows the user to install them.
compareSemver(String version, String other) int
Compares a version against other returns negative if version is ordered before positive if version is ordered after Doesnt considere incremental builds +VALUE 0 if its the same from cli_notify
createDartExportFile(List<String> exportPaths) → void
Generates the export file with the TKeys and TData files.
createFtsUtilsFile() → void
createLocalesFiles(Map<String, Map<String, String>> localesMap, Map<String, dynamic> masterMap) → void
Generates the json and dart files according to EnvConfig.
createSampleConfig() → void
createSampleContent() → void
Generates the sample template content when no fts --config is provided nor trconfig.yaml is detected in the current working directory.
createTKeyFileFromMap(JsonMap map, {bool save = false, bool includeToString = true}) String
Generates the TKeys file from the map.
createTKeyFileFromPath(String masterFile, {bool save = false}) String
createTranslationFile(List<String> locales, {required List<String> imports, required List<String> translationMaps, bool save = true}) String
Generates the TData.dart and the specified locales translations as dart files.
currentVersion() String?
Returns the current fts version. Validating if it runs in local mode CliConfig.isDev, or installed as snapshot.
error(dynamic arg1, [dynamic arg2 = '', dynamic arg3 = '', dynamic arg4 = '', dynamic arg5 = '', dynamic arg6 = '', dynamic arg7 = '', dynamic arg8 = '', dynamic arg9 = '', dynamic arg10 = '']) → void
prints messages to console with optional arguments using "red" pen.
extractStrings() Future<void>
Logic for fts extract
flutterHotReload() → void
formatDartFiles() → void
Format the selected dart folder with dartfmt if available.
getClassName(String name) String
gsheetError(GSheetsException e) → void
joinDir(List<String> paths) String
Shortcut utility to join paths properly in different environments. Alias of buildPath
json2yaml(Map<String, dynamic> json, {YamlStyle yamlStyle = YamlStyle.generic}) String
Converts JSON to YAML representation
langInfoFromKey(String key) LangInfo
Resolve Locale information LangInfo through the locale key (es, en). Instead of null, if languageCode not found, returns an empty LangInfo
loadEnv({String path = defaultConfigEnvPath, YamlMap? parsedDoc}) → void
Loads the configuration file from path.
moveFile(File sourceFile, String newPath) Future<File>
Moves a file in the system in async way.
normLocale(String localeString, [String targetSeparator = '_']) String
Normalizes localeString with targetSeparator to have consistency around the naming conventions usage in the CLI (and other tools)
openJson(String filepath) JsonMap
Reads filepath as a json Map. If file doesn't exists, returns empty Map.
openString(String path) String
Reads the contents of the path file as String. If files doesn't exists, returns empty String.
openYaml(String path) String
prettyJson(dynamic json) String
Encodes a json into a tabular format for easy redeability.
printVersion() Future<void>
shows the version number in the Terminal.
putVarsInMap(Map<String, Map<String, String>> map) → void
readPubSpec() → void
Reads the pubspec.yaml file and stores it in pubSpecStr and pubSpecMap
replaceVars(VarsCap vars) String
runPubGet() → void
sanitizeLocale(String locale, {bool throwOnError = false, bool verbose = true}) String
saveJson(String filepath, dynamic json, {bool beautify = false}) → void
Writes json in filepath, with the option to beautify the string.
saveLocaleJsonAsset(String localeName, KeyMap map, {bool beautify = false}) → void
Saves localeName translation map in EnvConfig.outputJsonDir. With the option to beautify the json string output.
saveString(String path, String content) → void
Save the content in path file, creating the path if doesn't exists.
setConfig(ArgResults res) → void
Reads the config from res
setCredentials({String? path, Map? json}) → void
startConfig(String path) → void
Initializes the supplied configuration from path
trace(dynamic arg1, [dynamic arg2 = '', dynamic arg3 = '', dynamic arg4 = '', dynamic arg5 = '', dynamic arg6 = '', dynamic arg7 = '', dynamic arg8 = '', dynamic arg9 = '', dynamic arg10 = '']) → void
Prints message to console using optional arguments to avoid complex string interpolation.
upgrade() Future<void>
runs the upgrade command: fts upgrade
warning(dynamic arg1, [dynamic arg2 = '', dynamic arg3 = '', dynamic arg4 = '', dynamic arg5 = '']) → void
prints messages to console with optional arguments using "orange" pen.
watchChanges() Future<void>
Watches for changes in the config.yaml and the config.entry_file basedir (where your master strings are).

Typedefs

JsonMap = Map<String, dynamic>
KeyMap = Map<String, String>
MapString = Map<String, String>