diff --git a/doc/autoyast.md b/doc/autoyast.md
index b936505583..c0337cc57a 100644
--- a/doc/autoyast.md
+++ b/doc/autoyast.md
@@ -126,10 +126,28 @@ For the first user, the following elements are supported:
| user_password | Yes | password | |
| username | Yes | userName | |
-### `keyboard`, `language` and `timezone`
+### `keyboard`
-These sections are rather simple, but we need to do some mapping between AutoYaST and Agama values.
-Additionally, the `hwclock` element is not present in Agama.
+Only the `keymap` element is translated. The rest of options are ignored in YaST and they are not
+even documented in the AutoYaST handbook.
+
+| AutoYaST | Supported | Agama | Comment |
+| -------- | ---------- | ------------- | ------------------------------ |
+| keymap | Yes | l10n.keyboard | Should we rename it to keymap? |
+| capslock | Deprecated | | |
+| delay | Deprecated | | |
+| discaps | Deprecated | | |
+| numlock | Deprecated | | |
+| rate | Deprecated | | |
+| scrlock | Deprecated | | |
+| tty | Deprecated | | |
+
+### `language`
+
+| AutoYaST | Supported | Agama | Comment |
+| --------- | --------- | -------------- | ------------------------- |
+| language | Yes | l10n.languages | First element of the list |
+| languages | Yes | l10n.languages | |
### `networking`
@@ -228,6 +246,13 @@ About the `slp_discoverty` element, Agama does not support [SLP] at all?
[SLP]: https://documentation.suse.com/sles/15-SP5/single-html/SLES-administration/#cha-slp
+### `timezone`
+
+| AutoYaST | Supported | Agama | Comment |
+| -------- | --------- | ------------- | ------- |
+| timezone | Yes | l10n.timezone | |
+| hwclock | No | | |
+
## Unsupported sections
- `FCoE`
diff --git a/service/lib/agama/autoyast/converter.rb b/service/lib/agama/autoyast/converter.rb
index 225df0d8e8..76f340a96f 100755
--- a/service/lib/agama/autoyast/converter.rb
+++ b/service/lib/agama/autoyast/converter.rb
@@ -23,6 +23,7 @@
require "yast"
require "autoinstall/script_runner"
require "autoinstall/script"
+require "agama/autoyast/l10n_reader"
require "agama/autoyast/product_reader"
require "agama/autoyast/root_reader"
require "agama/autoyast/software_reader"
@@ -119,6 +120,7 @@ def export_profile(profile)
root = Agama::AutoYaST::RootReader.new(profile)
software = Agama::AutoYaST::SoftwareReader.new(profile)
product = Agama::AutoYaST::ProductReader.new(profile)
+ l10n = Agama::AutoYaST::L10nReader.new(profile)
storage = Agama::AutoYaST::StorageReader.new(profile)
user.read
@@ -126,6 +128,7 @@ def export_profile(profile)
.merge(software.read)
.merge(product.read)
.merge(storage.read)
+ .merge(l10n.read)
end
def import_yast
diff --git a/service/lib/agama/autoyast/l10n_reader.rb b/service/lib/agama/autoyast/l10n_reader.rb
new file mode 100644
index 0000000000..1c17a2f52c
--- /dev/null
+++ b/service/lib/agama/autoyast/l10n_reader.rb
@@ -0,0 +1,79 @@
+#!/usr/bin/env ruby
+# frozen_string_literal: true
+
+# Copyright (c) [2024] SUSE LLC
+#
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, contact SUSE LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require "yast"
+
+# :nodoc:
+module Agama
+ module AutoYaST
+ class L10nReader
+ # @param profile [ProfileHash] AutoYaST profile
+ def initialize(profile)
+ @profile = profile
+ end
+
+ # @return [Hash] Agama "l10n" section
+ def read
+ l10n = keyboard
+ .merge(languages)
+ .merge(timezone)
+ l10n.empty? ? {} : { "l10n" => l10n }
+ end
+
+ private
+
+ attr_reader :profile
+
+ def keyboard
+ section = profile.fetch_as_hash("keyboard")
+ keymap = section["keymap"]
+ return {} if keymap.nil?
+
+ { "keyboard" => keymap.to_s }
+ end
+
+ def languages
+ section = profile.fetch_as_hash("language")
+ primary = section["language"]
+ secondary = section["languages"].to_s.split(",").map(&:strip)
+
+ languages = []
+ languages.push(primary.to_s) unless primary.nil?
+ languages.concat(secondary)
+
+ with_encoding = languages.map do |lang|
+ lang.include?(".") ? lang : "#{lang}.UTF-8"
+ end
+
+ with_encoding.empty? ? {} : { "languages" => with_encoding.uniq }
+ end
+
+ def timezone
+ section = profile.fetch_as_hash("timezone")
+ timezone = section["timezone"]
+ return {} if timezone.nil?
+
+ { "timezone" => timezone.to_s }
+ end
+ end
+ end
+end
diff --git a/service/test/agama/autoyast/converter_test.rb b/service/test/agama/autoyast/converter_test.rb
index b9f6107dc6..b11937e10a 100644
--- a/service/test/agama/autoyast/converter_test.rb
+++ b/service/test/agama/autoyast/converter_test.rb
@@ -118,6 +118,15 @@
"password" => "12345678", "fullName" => "Jane Doe")
end
end
+
+ it "exports l10n settings" do
+ subject.to_agama(workdir)
+ expect(result["l10n"]).to include(
+ "languages" => ["en_US.UTF-8"],
+ "timezone" => "Atlantic/Canary",
+ "keyboard" => "us"
+ )
+ end
end
context "when an invalid profile is given" do
diff --git a/service/test/agama/autoyast/l10n_reader_test.rb b/service/test/agama/autoyast/l10n_reader_test.rb
new file mode 100644
index 0000000000..34952cf6d1
--- /dev/null
+++ b/service/test/agama/autoyast/l10n_reader_test.rb
@@ -0,0 +1,102 @@
+# frozen_string_literal: true
+
+# Copyright (c) [2024] SUSE LLC
+#
+# All Rights Reserved.
+#
+# This program is free software; you can redistribute it and/or modify it
+# under the terms of version 2 of the GNU General Public License as published
+# by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, contact SUSE LLC.
+#
+# To contact SUSE LLC about this file by physical or electronic mail, you may
+# find current contact information at www.suse.com.
+
+require_relative "../../test_helper"
+require "yast"
+require "agama/autoyast/l10n_reader"
+
+Yast.import "Profile"
+
+describe Agama::AutoYaST::L10nReader do
+ let(:profile) do
+ {}
+ end
+
+ subject do
+ described_class.new(Yast::ProfileHash.new(profile))
+ end
+
+ describe "#read" do
+ context "when there is no l10n-related sections" do
+ let(:profile) { {} }
+
+ it "returns an empty hash" do
+ expect(subject.read).to be_empty
+ end
+ end
+
+ context "when a keymap is defined" do
+ let(:profile) do
+ { "keyboard" => { "keymap" => "us" } }
+ end
+
+ it "includes a 'keyboard' key with its value" do
+ l10n = subject.read["l10n"]
+ expect(l10n["keyboard"]).to eq("us")
+ end
+ end
+
+ context "when there are primary and secondary languages" do
+ let(:profile) do
+ {
+ "language" => {
+ "language" => "en_US.UTF-8",
+ "languages" => "es_ES.UTF-8, cs_CZ.UTF-8"
+ }
+ }
+ end
+
+ it "includes a 'languages' key with all the languages" do
+ l10n = subject.read["l10n"]
+ expect(l10n["languages"]).to eq(["en_US.UTF-8", "es_ES.UTF-8", "cs_CZ.UTF-8"])
+ end
+
+ context "when the encoding is not included" do
+ let(:profile) do
+ {
+ "language" => {
+ "language" => "en_US",
+ "languages" => "es_ES"
+ }
+ }
+ end
+
+ it "uses the UTF-8 encoding" do
+ l10n = subject.read["l10n"]
+ expect(l10n["languages"]).to eq(["en_US.UTF-8", "es_ES.UTF-8"])
+ end
+ end
+ end
+
+ context "when a timezone is defined" do
+ let(:profile) do
+ { "timezone" => { "timezone" => "Europe/Berlin" } }
+ end
+
+ it "includes a 'keyboard' key with its value" do
+ l10n = subject.read["l10n"]
+ expect(l10n["timezone"]).to eq("Europe/Berlin")
+ end
+ end
+ end
+end
+
+
diff --git a/service/test/fixtures/profiles/simple.xml b/service/test/fixtures/profiles/simple.xml
index 1a0fd55eb7..58bd3ae0f4 100644
--- a/service/test/fixtures/profiles/simple.xml
+++ b/service/test/fixtures/profiles/simple.xml
@@ -15,6 +15,14 @@
en_US
+
+ Atlantic/Canary
+
+
+
+ us
+
+
/dev/vda