1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-02-04 07:51:50 +00:00

locale_gen: search for available locales in /usr/local as well (#11046)

* locale_gen: search for available locales in /usr/local as well

* better var name

* add test for /usr/local

* Apply suggestions from code review

Co-authored-by: Felix Fontein <felix@fontein.de>

* skip /usr/local/ for Archlinux

* improve/update documentation

* add license file for the custom locale

* add changelog frag

* Update plugins/modules/locale_gen.py

Co-authored-by: Felix Fontein <felix@fontein.de>

* Update changelogs/fragments/11046-locale-gen-usrlocal.yml

Co-authored-by: Felix Fontein <felix@fontein.de>

---------

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Alexei Znamensky 2025-11-16 11:17:08 +13:00 committed by GitHub
parent 5617d57c8c
commit 98aca27a8b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 247 additions and 26 deletions

View file

@ -0,0 +1,120 @@
comment_char %
escape_char /
% This file is part of the GNU C Library and contains locale data.
% The Free Software Foundation does not claim any copyright interest
% in the locale data contained in this file. The foregoing does not
% affect the license of the GNU C Library as a whole. It does not
% exempt you from the conditions of the license if your use would
% otherwise be governed by that license.
LC_IDENTIFICATION
title "English locale for the USA with ISO formats"
language "American English"
category "i18n:2012";LC_IDENTIFICATION
category "i18n:2012";LC_CTYPE
category "i18n:2012";LC_COLLATE
category "i18n:2012";LC_TIME
category "i18n:2012";LC_NUMERIC
category "i18n:2012";LC_MONETARY
category "i18n:2012";LC_MESSAGES
category "i18n:2012";LC_PAPER
category "i18n:2012";LC_NAME
category "i18n:2012";LC_ADDRESS
category "i18n:2012";LC_TELEPHONE
category "i18n:2012";LC_MEASUREMENT
END LC_IDENTIFICATION
LC_TIME
day "Sunday";/
"Monday";/
"Tuesday";/
"Wednesday";/
"Thursday";/
"Friday";/
"Saturday"
abday "Sun";/
"Mon";/
"Tue";/
"Wed";/
"Thu";/
"Fri";/
"Sat"
mon "January";/
"February";/
"March";/
"April";/
"May";/
"June";/
"July";/
"August";/
"September";/
"October";/
"November";/
"December"
abmon "Jan";/
"Feb";/
"Mar";/
"Apr";/
"May";/
"Jun";/
"Jul";/
"Aug";/
"Sep";/
"Oct";/
"Nov";/
"Dec"
date_fmt "%a %d %b %Y %T %Z"
d_t_fmt "%a %d %b %Y %T"
d_fmt "%Y-%m-%d"
t_fmt "%T"
t_fmt_ampm ""
am_pm "";""
week 7;19971130;4
first_weekday 2
END LC_TIME
LC_CTYPE
copy "en_US"
END LC_CTYPE
LC_COLLATE
copy "en_US"
END LC_COLLATE
LC_MONETARY
copy "en_US"
END LC_MONETARY
LC_NUMERIC
decimal_point "."
thousands_sep ","
grouping 3;3
END LC_NUMERIC
LC_MESSAGES
copy "en_US"
END LC_MESSAGES
LC_PAPER
copy "i18n"
END LC_PAPER
LC_TELEPHONE
copy "en_US"
END LC_TELEPHONE
LC_MEASUREMENT
copy "i18n"
END LC_MEASUREMENT
LC_NAME
copy "en_US"
END LC_NAME
LC_ADDRESS
copy "en_US"
END LC_ADDRESS

View file

@ -0,0 +1,3 @@
Copyright (c) Ansible Project
GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
SPDX-License-Identifier: GPL-3.0-or-later

View file

@ -0,0 +1,85 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Arch-less block
when: ansible_distribution not in ['Archlinux']
block:
- name: Is the locale we're going to test against installed?
command: locale -a
register: initial_state
- name: Make sure the locale is not available
community.general.locale_gen:
name: en_US@iso
state: absent
ignore_errors: true
register: not_available
- name: Ensure /usr/local/share/i18n/
ansible.builtin.file:
path: /usr/local/share/i18n/locales
state: directory
mode: '0755'
- name: Back up /etc/locale.gen
ansible.builtin.copy:
src: /etc/locale.gen
dest: /etc/locale.gen.bkp
remote_src: true
- name: Add line to /etc/locale.gen
ansible.builtin.shell: >
echo "# en_US@iso UTF-8" >> /etc/locale.gen
- name: Copy custom locale
ansible.builtin.copy:
dest: /usr/local/share/i18n/locales/en_US@iso
src: en_US@iso
mode: '0644'
- name: Add custom locale to SUPPORTED
ansible.builtin.copy:
dest: /usr/local/share/i18n/SUPPORTED
content: |
en_US@iso UTF-8
mode: '0644'
- name: Make sure the locale is available
community.general.locale_gen:
name: en_US@iso
state: absent
register: available
- name: Make sure the locale is installed
community.general.locale_gen:
name: en_US@iso
state: present
register: installed
- name: Check assertions
ansible.builtin.assert:
that:
- not_available is failed
- >
"locales you have entered are not available on your system: en_US@iso" in not_available.msg
- available is not changed
- installed is changed
always:
- name: Make sure the locale is not installed
community.general.locale_gen:
name: en_US@iso
state: absent
- name: Remove /usr/local/share/i18n/
ansible.builtin.file:
path: /usr/local/share/i18n/
state: absent
- name: Restore /etc/locale.gen
ansible.builtin.copy:
src: /etc/locale.gen.bkp
dest: /etc/locale.gen
remote_src: true

View file

@ -17,3 +17,6 @@
loop: "{{ locale_list_basic }}"
loop_control:
loop_var: locale_basic
- name: Run tests for 11046
ansible.builtin.include_tasks: 11046-usrlocal.yml