diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ea8282b..181efff 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,7 @@ jobs: "git-lfs", "go", "jfrog-cli", + "locale", "make", "mingw", "node", diff --git a/README.md b/README.md index 389eda0..7ec8764 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ Below is a list with included features, click on the link for more details. | [go](./features/src/go/README.md) | A feature which installs Go. | | [instant-client](./features/src/instant-client/README.md) | A feature which installs the Oracle Instant Client basic package | | [jfrog-cli](./features/src/jfrog-cli/README.md) | A feature which installs the JFrog CLI. | +| [locale](./features/src/locale/README.md) | A feature which configures system locale and language settings. | | [make](./features/src/make/README.md) | A feature which installs GNU Make. | | [mingw](./features/src/mingw/README.md) | A feature which installs MinGW (Minimalist GNU for Windows) cross-compilers and tools. | | [node](./features/src/node/README.md) | A package which installs Node.js. | diff --git a/build/build.go b/build/build.go index 7410fee..8a09dda 100644 --- a/build/build.go +++ b/build/build.go @@ -28,6 +28,7 @@ var featureList = []string{ "go", "instant-client", "jfrog-cli", + "locale", "make", "mingw", "node", @@ -145,6 +146,17 @@ func init() { return publishFeature("jfrog-cli") }) + ////////// locale + gotaskr.Task("Feature:locale:Package", func() error { + return packageFeature("locale") + }) + gotaskr.Task("Feature:locale:Test", func() error { + return testFeature("locale") + }) + gotaskr.Task("Feature:locale:Publish", func() error { + return publishFeature("locale") + }) + ////////// make gotaskr.Task("Feature:make:Package", func() error { return packageFeature("make") diff --git a/features/src/locale/NOTES.md b/features/src/locale/NOTES.md new file mode 100644 index 0000000..d4bbd99 --- /dev/null +++ b/features/src/locale/NOTES.md @@ -0,0 +1,16 @@ +## Notes + +Currently, you still need to add the appropriate language as environment variable to your container. You can do this in the `devcontainer.json` file like: +```json +{ + "containerEnv": { + "LANG": "de_CH.UTF-8", + "LANGUAGE": "de_CH.UTF-8", + "LC_ALL": "de_CH.UTF-8" + } +} +``` + +### System Compatibility + +Debian, Ubuntu diff --git a/features/src/locale/README.md b/features/src/locale/README.md new file mode 100755 index 0000000..3fbdeba --- /dev/null +++ b/features/src/locale/README.md @@ -0,0 +1,36 @@ +# Set a specific locale (locale) + +A package which allows setting the locale. + +## Example Usage + +```json +"features": { + "ghcr.io/postfinance/devcontainer-features/locale:0.1.0": { + "locale": "en_US" + } +} +``` + +## Options + +| Option | Description | Type | Default Value | Proposals | +|-----|-----|-----|-----|-----| +| locale | The locale to set. | string | en_US | de_CH, en_US | + +## Notes + +Currently, you still need to add the appropriate language as environment variable to your container. You can do this in the `devcontainer.json` file like: +```json +{ + "containerEnv": { + "LANG": "de_CH.UTF-8", + "LANGUAGE": "de_CH.UTF-8", + "LC_ALL": "de_CH.UTF-8" + } +} +``` + +### System Compatibility + +Debian, Ubuntu diff --git a/features/src/locale/devcontainer-feature.json b/features/src/locale/devcontainer-feature.json new file mode 100644 index 0000000..a8eac9c --- /dev/null +++ b/features/src/locale/devcontainer-feature.json @@ -0,0 +1,17 @@ +{ + "id": "locale", + "version": "0.1.0", + "name": "Set a specific locale", + "description": "A package which allows setting the locale.", + "options": { + "locale": { + "type": "string", + "proposals": [ + "de_CH", + "en_US" + ], + "default": "en_US", + "description": "The locale to set." + } + } +} \ No newline at end of file diff --git a/features/src/locale/install.sh b/features/src/locale/install.sh new file mode 100644 index 0000000..7d8a208 --- /dev/null +++ b/features/src/locale/install.sh @@ -0,0 +1,4 @@ +apt-get update && apt-get install -y locales && rm -rf /var/lib/apt/lists/* + +localedef -i $LOCALE -f UTF-8 $LOCALE.UTF-8 +update-locale LANG=$LOCALE.UTF-8 diff --git a/features/test/locale/de_ch.sh b/features/test/locale/de_ch.sh new file mode 100644 index 0000000..0c2a9c8 --- /dev/null +++ b/features/test/locale/de_ch.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh" +[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh" + +check_version "$(locale -k LC_TIME)" "abday=\"So;Mo;Di;Mi;Do;Fr;Sa\"" + +check_version "$(env)" "LANG=de_CH.UTF-8" +check_version "$(env)" "LANGUAGE=de_CH.UTF-8" +check_version "$(env)" "LC_ALL=de_CH.UTF-8" diff --git a/features/test/locale/en_us.sh b/features/test/locale/en_us.sh new file mode 100644 index 0000000..47ff36a --- /dev/null +++ b/features/test/locale/en_us.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e + +[[ -f "$(dirname "$0")/../functions.sh" ]] && source "$(dirname "$0")/../functions.sh" +[[ -f "$(dirname "$0")/functions.sh" ]] && source "$(dirname "$0")/functions.sh" + +check_version "$(locale -k LC_TIME)" "abday=\"Sun;Mon;Tue;Wed;Thu;Fri;Sat\"" + +check_version "$(env)" "LANG=en_US.UTF-8" +check_version "$(env)" "LANGUAGE=en_US.UTF-8" +check_version "$(env)" "LC_ALL=en_US.UTF-8" diff --git a/features/test/locale/scenarios.json b/features/test/locale/scenarios.json new file mode 100644 index 0000000..86f919e --- /dev/null +++ b/features/test/locale/scenarios.json @@ -0,0 +1,38 @@ +{ + "de_ch": { + "build": { + "dockerfile": "Dockerfile", + "options": [ + "--add-host=host.docker.internal:host-gateway" + ] + }, + "features": { + "./locale": { + "locale": "de_CH" + } + }, + "containerEnv": { + "LANG": "de_CH.UTF-8", + "LANGUAGE": "de_CH.UTF-8", + "LC_ALL": "de_CH.UTF-8" + } + }, + "en_us": { + "build": { + "dockerfile": "Dockerfile", + "options": [ + "--add-host=host.docker.internal:host-gateway" + ] + }, + "features": { + "./locale": { + "locale": "en_US" + } + }, + "containerEnv": { + "LANG": "en_US.UTF-8", + "LANGUAGE": "en_US.UTF-8", + "LC_ALL": "en_US.UTF-8" + } + } +} \ No newline at end of file diff --git a/features/test/locale/test-images.json b/features/test/locale/test-images.json new file mode 100644 index 0000000..baaeb21 --- /dev/null +++ b/features/test/locale/test-images.json @@ -0,0 +1,5 @@ +[ + "mcr.microsoft.com/devcontainers/base:debian-11", + "mcr.microsoft.com/devcontainers/base:debian-12", + "mcr.microsoft.com/devcontainers/base:ubuntu-24.04" +] \ No newline at end of file