-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
FROM python:3.8-slim | ||
|
||
WORKDIR /app | ||
|
||
COPY requirements.txt ./ | ||
COPY setup.py ./ | ||
COPY config.example.toml ./config.toml | ||
|
||
RUN pip install --no-cache-dir -r requirements.txt | ||
|
||
COPY . . | ||
|
||
COPY entrypoint.sh ./ | ||
|
||
RUN chmod +x entrypoint.sh | ||
|
||
ENTRYPOINT ["./entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/bash | ||
|
||
# Verify that the correct number of arguments have been passed | ||
if [ "$#" -ne 4 ]; then | ||
echo "Usage: $0 <source_language> <target_language> <input_file> <output_file>" | ||
exit 1 | ||
fi | ||
|
||
# Assign arguments to variables | ||
SOURCE_LANGUAGE=$1 | ||
TARGET_LANGUAGE=$2 | ||
INPUT_FILE=$3 | ||
OUTPUT_FILE=$4 | ||
|
||
# Read the content of the input file | ||
TEXT=$(cat "$INPUT_FILE") | ||
|
||
# Execute the translation | ||
TRANSLATION=$(python -c " | ||
from aphra import translate | ||
result = translate('$SOURCE_LANGUAGE', '$TARGET_LANGUAGE', '''$TEXT''', config_file='config.toml') | ||
print(result) | ||
") | ||
|
||
# Save the translation to the output file | ||
echo "$TRANSLATION" > "$OUTPUT_FILE" | ||
|
||
echo "Translation completed. See file $OUTPUT_FILE for the result." |