#!/bin/sh
###############################################################################
# BRLTTY - A background process providing access to the console screen (when in
#          text mode) for a blind person using a refreshable braille display.
#
# Copyright (C) 1995-2021 by The BRLTTY Developers.
#
# BRLTTY comes with ABSOLUTELY NO WARRANTY.
#
# This is free software, placed under the terms of the
# GNU Lesser General Public License, as published by the Free Software
# Foundation; either version 2.1 of the License, or (at your option) any
# later version. Please see the file LICENSE-LGPL for details.
#
# Web Page: http://brltty.app/
#
# This software is maintained by Dave Mielke <dave@mielke.cc>.
###############################################################################

set -e
umask 022

poExtension="po"
moExtension="mo"

. "$(dirname "${0}")/../../brltty-prologue.sh"
addProgramParameter "source" poDirectory "the directory containing the .${poExtension} files"
addProgramParameter "target" moDirectory "the directory in which to create the .${moExtension} files"
addProgramParameter "domain" moName "the domain name for the .${moExtension} files"
parseProgramArguments "${@}"

for poPath in "${poDirectory}/"*".${poExtension}"
do
   poFile="${poPath##*/}"
   poName="${poFile%.*}"

   moPath="${moDirectory}/${poName}/LC_MESSAGES"
   mkdir -p -- "${moPath}"

   moPath="${moPath}/${moName}.${moExtension}"
   msgfmt --no-hash --output-file="${moPath}" -- "${poPath}"
done

exit 0
