-
Notifications
You must be signed in to change notification settings - Fork 0
Home
There are a number of places in which a UI might want to show a list of Helm charts, or a list of Kubernetes apps (e.g. deployments). For example, a Helm chart repository browser might want to list the list of available charts. Or, you might have a UI for a kubernetes cluster, in which you wish to show the list of active Kubernetes services. First of all, it'd be better to list them with descriptive texts rather than the chart name or deployment name label.
Additionally, if the UI is localized, it's better to show localized names rather than showing in English.
For these reasons, we've decided to create a spec for describing Kubernetes apps & Helm charts with localization support.
A Kubernetes ConfigMap
object with a object.ravin.soc1.ir/type: l10n
label is considered an object containing object description with localization for objects which are identified with matching app.kubernetes.io/name
and app.kubernetes.io/instance
labels.
There can be multiple ConfigMap
objects for a single app/chart, in which case the data from all of them is merged. If the same key appears in multiple objects, those with higher priority will override others. Each localization ConfigMap object has a object.ravin.soc1.ir/priority
metadata, which starts from 1 (lowest priority). This is mainly useful when a third-party wants to provide more data or more appropriate description for a dependency.
The ConfigMap
data is a list of key/values in which each value provides the description of a given key. You can use any number of keys you want, but there are two reserved keys which we suggest to use:
-
Name
: provides a descriptive name for the app -
Instance
: an optional description for this specific instance of the app, when multiple instance of the same app is used in a single cluster
For each key, any number of translation can be provided. The translation keys are named as: <key>.<langcode>
, e.g. for the Name
key translations are provided with keys like: Name.fa
, Name.de
, ...
This is an example description/localization ConfigMap:
kind: ConfigMap
apiVersion: v1
metadata:
name: demo-shop-l10n
namespace: demo
labels:
app.kubernetes.io/instance: shop-demo2
app.kubernetes.io/name: shop
helm.sh/chart: shop-0.1.0
object.ravin.soc1.ir/type: l10n
annotations:
object.ravin.soc1.ir/priority: '1'
data:
Name: My Shop
Name.fa: فروشگاه من
helm-l10n
plugin for Helm creates the above ConfigMap
object automatically from its inputs, so it is not necessary to create it manually. However, consumers should be aware of this object so that they can use it.
The helm-l10n
plugins helps to create descriptions with localization for a chart and its subcharts. It creates a sample chart.l10n.in
input file in a chart's directory, which is the one which is edited by the developer(s) of a chart. It is basically in Desktop file format, and contains reference text for describing a chart and its subcharts.
The plugin extracts text messages from chart.l10n.in
file and creates POT
file and updates existing PO
files for translation. So, translators can do their job using the familiar PO
files.
Finally, the plugin puts together the text from chart.l10n.in
file and all translations in PO
files and creates the final chart.l10n
file which should be included in the chart package. chart.l10n
files is also in Desktop file format, so anybody who wants to extract descriptive text directly from a chart archive can use this file. When a chart is installed, appropriate ConfigMap
objects described above are automatically generated from the chart.l10n
file included in the chart.
Example chart.l10n.in
:
Name=My Shop
[myshop-db:{{ .Release.Name }}]
Name=PostgreSQL
Instance=My Shop
An example generated chart.l10n
file from the above file and translations provided in PO
files:
Name[fa]=فروشگاه من
Name=My Shop
[myshop-db:{{ .Release.Name }}]
Name[fa]=پایگاه دادهٔ پستگرس
Name=PostgreSQL
Instance[fa]=فروشگاه من
Instance=My Shop