#!/bin/sh
#
# Output the specified Error code in the target language using DSM language setting.
# Default to English if the error code is not available in the target language
#
# Usage:
#   message-text ErrorName OutputFile [Optional args]

# Where:
#   ErrorName      - Name assigned to the error
#   OutputFile     - Path to output file (typically either Migration.log or SYNOPKG_TEMP_LOGFILE )
#   Optional Args  - Mechanism to pass host-specific values into the error message (provides context & detail to user)
#
# Modularity:
#
#   If a `message-text-<lang>` file exists, call it for the specific error text.
#   Else default to `message-text-enu` (English)
#
Error=0

# Path to this script
ScriptDir="$(dirname "$0")"

# Check if language supported
if [ -e "$ScriptDir/message-text-$SYNOPKG_DSM_LANGUAGE" ]; then

  # Call language module for error text
  "$ScriptDir/message-text-$SYNOPKG_DSM_LANGUAGE" "$1" "$2" "$3" "$4" "$5" "$6"
  Error=$?
else

  # Call English module by default if language not supported
  "$ScriptDir/message-text-enu" "$1" "$2" "$3" "$4" "$5" "$6"
  Error=$?
fi

exit $Error
