在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):s0nerik/goloc开源软件地址(OpenSource Url):https://github.com/s0nerik/goloc开源编程语言(OpenSource Language):Go 98.2%开源软件介绍(OpenSource Introduction):goloc
Table of Contents
Features
Supported OS / architecturesgoloc can be built for each OS/architecture supported by golang, but release archives contain binaries only for amd64 architecture for macOS, Linux and Windows. Supported formatsSetup
Localization documentEach localization document consists of formats and localizations sheets. One localization document can have multiple sheets for both. The simplest way to create a new goloc-compatible localization document is to copy the sample spreadsheet. However, you can easily create a goloc-compatible localization document yourself just by following the simple requirements described below. Localizations sheetOn the example above you can see a goloc-compatible localizations sheet. The rules to make a localizations sheet goloc-compatible are:
Formats sheetOn the example above you can see a goloc-compatible formats sheet. The rules to make a formats sheet goloc-compatible are:
Usage
AndroidNo special configuration in code is required. Example gradle task specification: task "fetchLocalizations"(type: Exec) {
def osName = System.getProperty('os.name').toLowerCase()
def isWindows = osName.contains("win")
def isMac = osName.contains("mac")
def isUnix = osName.contains("nix") || osName.contains("nux") || osName.contains("aix")
def params = [
'--credentials', "goloc/client_secret.json",
'--platform', 'android',
'--spreadsheet', '1MbtglvGyEey3gH8yh4c9QovCIbtl5EcwqWqTZUiNga8',
'--tab', "localizations",
"--key-column", "key",
'--resources', "app/src/main/res/",
'--default-localization', 'en',
'--default-localization-file-path', "app/src/main/res/values/localized_strings.xml"
]
if (isWindows) {
params = ['cmd', '/c', 'goloc\\windows_amd64.exe'] + params
} else if (isMac) {
params = ['./goloc/darwin_amd64'] + params
} else if (isUnix) {
params = ['./goloc/linux_amd64'] + params
} else {
logger.error('Your OS is not supported.')
return
}
commandLine params
} FlutterLocalized strings can be accessed through Requirements:
class DefaultIntlLocaleDelegate extends LocalizationsDelegate<Null> {
@override
bool isSupported(Locale locale) => true;
@override
Future<Null> load(Locale locale) {
Intl.defaultLocale = locale.toLanguageTag();
return Future.value(null);
}
@override
bool shouldReload(LocalizationsDelegate<AppLocalizations> old) => false;
} Example bash localization script: #!/bin/bash
case "$OSTYPE" in
darwin*) EXECUTABLE="darwin_amd64" ;;
linux*) EXECUTABLE="linux_amd64" ;;
msys*) EXECUTABLE="windows_amd64.exe" ;;
*)
echo "Platform is not supported: $OSTYPE"
exit 1
;;
esac
goloc/${EXECUTABLE} -c goloc/client_secret.json -p flutter -s 1MbtglvGyEey3gH8yh4c9QovCIbtl5EcwqWqTZUiNga8 -t localizations -r lib/intl macOS Catalina usage notesDue to the security improvements in the macOS Catalina, any 3rd party application downloaded from the internet has to be notarized to be launched without additional actions from the user side. Since goloc is entirely free, I can't afford Apple Developer Program subscription for notarizing macOS builds. Luckily, Apple has left a way to launch a non-notarized app, but it requires some actions. Here's the instruction on how to launch goloc on macOS Catalina:
LicenseReleased under the MIT License. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论