#!/usr/bin/env sh

set -e

usage() {
  echo "Usage: $0 [ -s SEPARATOR ]"
}

while getopts 'hs:' opt; do
  case $opt in
    h)
      usage
      exit 0
      ;;
    s)
      SEPARATOR="$OPTARG"
      ;;
    :)
      echo "Error: -$OPTARG requires an argument"
      exit 1
      ;;
    *)
      usage
      exit 1
      ;;
  esac
done
shift $((OPTIND - 1))

set -- $(cat /proc/cmdline)
for x in "$@"; do
  case "$x" in
    *localization=*)
      LOCALE=${x#*=}
      if [ -n "$SEPARATOR" ]; then
        LOCALE=${LOCALE//[.]/$SEPARATOR}
      fi
      echo "$LOCALE"
      ;;
  esac
done
