summaryrefslogtreecommitdiff
path: root/tools/collate/mkcollator.sh
blob: fc17d93d6ee6e0610b5504e8f57841d881bb7b4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/bash

# SPDX-FileCopyrightText: 2023 jacqueline <me@jacqueline.id.au>
#
# SPDX-License-Identifier: GPL-3.0-only

set -eu

if [ -z "${2:-}" ]; then
  name="Generic"
  locale="iso14651_t1"
else
  name="$1"
  locale="$2"
fi

working_dir=$(mktemp -d)

echo -n "$name" | dd iflag=fullblock bs=8 count=1 conv=sync of="$working_dir/name"
localedef -f UTF-8 -i "$locale" --no-archive "$working_dir" || true
cat "$working_dir/name" "$working_dir/LC_COLLATE" > "$name.LC_COLLATE"