-
Notifications
You must be signed in to change notification settings - Fork 1
Generate fr/gtfs_rts_strings.xml & ignore location inside agency name.
#730
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
09ae99d
Generate `values-fr/gtfs_rts_strings.xml`
mmathieum 60bd66d
missing
mmathieum 89667b4
Ignore agency location when inside agency long name (label)
mmathieum 1636921
PR comments
mmathieum 7b8135d
PR comments
mmathieum 149bef1
PR comments
mmathieum 61e8c36
PR comments
mmathieum cd85389
PR comments
mmathieum File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
133 changes: 133 additions & 0 deletions
133
shared-modules/app-android/src/main/res/values-fr/MTgtfs_rts_strings.xml.MT.sh
This file contains hidden or 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,133 @@ | ||
| #!/bin/bash | ||
| SCRIPT_DIR="$(dirname "$0")"; | ||
|
|
||
| ROOT_DIR="$SCRIPT_DIR/../../../../../../.."; | ||
| COMMONS_DIR="${ROOT_DIR}/commons"; | ||
| source ${COMMONS_DIR}/commons.sh; | ||
|
|
||
| setGitProjectName; | ||
|
|
||
| setIsCI; | ||
|
|
||
| APP_ANDROID_DIR="${ROOT_DIR}/app-android"; | ||
| SRC_DIR="${APP_ANDROID_DIR}/src"; | ||
| MAIN_DIR="${SRC_DIR}/main"; | ||
| RES_DIR="${MAIN_DIR}/res"; | ||
| VALUES_DIR="${RES_DIR}/values"; | ||
| VALUES_FR_DIR="${RES_DIR}/values-fr"; | ||
|
|
||
| LANG_FR_FILE="${ROOT_DIR}/config/lang/fr"; | ||
| if [[ ! -f "$LANG_FR_FILE" && ! -d "$VALUES_FR_DIR" ]]; then | ||
| echo ">> Generating values-fr/gtfs_rts_strings.xml... SKIP (FR lang not supported)"; | ||
| exit 0; # ok | ||
| fi | ||
|
|
||
| GTFS_RDS_VALUES_FILE="${ROOT_DIR}/app-android/src/main/res/values/gtfs_rts_values.xml"; # do not change to avoid breaking compat w/ old modules | ||
| if [ ! -f "${GTFS_RDS_VALUES_FILE}" ]; then | ||
| echo ">> Generating values-fr/gtfs_rts_strings.xml... SKIP (not an rds agency)"; | ||
|
mmathieum marked this conversation as resolved.
|
||
| exit 0; # ok | ||
| fi | ||
|
|
||
| echo ">> Generating values-fr/gtfs_rts_strings.xml..."; | ||
|
|
||
| GTFS_RTS_STRINGS_FILE="${VALUES_FR_DIR}/gtfs_rts_strings.xml"; | ||
| mkdir -p "${VALUES_FR_DIR}"; | ||
| checkResult $?; | ||
|
mmathieum marked this conversation as resolved.
|
||
| if [ -f "${GTFS_RTS_STRINGS_FILE}" ]; then | ||
| echo ">> File '$GTFS_RTS_STRINGS_FILE' already exist."; # compat with existing values-fr/gtfs_rts_strings.xml | ||
| exit 0; # compat w/ manually created file | ||
| fi | ||
|
|
||
| rm -f "${GTFS_RTS_STRINGS_FILE}"; | ||
| checkResult $?; | ||
| touch "${GTFS_RTS_STRINGS_FILE}"; | ||
| checkResult $?; | ||
|
mmathieum marked this conversation as resolved.
|
||
|
|
||
| CONFIG_DIR="${ROOT_DIR}/config"; | ||
| if [ ! -d "$CONFIG_DIR" ]; then | ||
| echo "$CONFIG_DIR doesn't exist!"; | ||
| exit 1; | ||
| fi | ||
|
|
||
| AGENCY_NAME_FILE="${CONFIG_DIR}/fr/agency_name"; | ||
| if [ ! -f "$AGENCY_NAME_FILE" ]; then | ||
| AGENCY_NAME_FILE="${CONFIG_DIR}/agency_name"; | ||
| fi | ||
| if [ ! -f "$AGENCY_NAME_FILE" ]; then | ||
| echo "$AGENCY_NAME_FILE doesn't exist!"; | ||
| exit 1; | ||
| fi | ||
|
|
||
| AGENCY_NAME_LONG=$(tail -n 1 $AGENCY_NAME_FILE); | ||
| if [ -z "$AGENCY_NAME_LONG" ]; then | ||
| echo "AGENCY_NAME_LONG is empty!"; | ||
| exit 1; | ||
| fi | ||
|
|
||
| AGENCY_NAME_SHORT=$(head -n 1 $AGENCY_NAME_FILE); | ||
| if [ -z "$AGENCY_NAME_SHORT" ]; then | ||
| echo "AGENCY_NAME_SHORT is empty!"; | ||
| exit 1; | ||
| fi | ||
|
|
||
| requireCommand "xmllint" "libxml2-utils"; | ||
| requireCommand "jq"; | ||
|
|
||
| GTFS_CONFIG_DIR="${CONFIG_DIR}/gtfs"; | ||
| GTFS_RDS_VALUES_GEN_FILE="${ROOT_DIR}/app-android/src/main/res/values/gtfs_rts_values_gen.xml"; # do not change to avoid breaking compat w/ old modules | ||
|
mmathieum marked this conversation as resolved.
|
||
| AGENCY_JSON_FILE="${GTFS_CONFIG_DIR}/agency.json"; | ||
| TYPE=-1; | ||
| if [ -f $GTFS_RDS_VALUES_GEN_FILE ]; then | ||
| # https://github.com/mtransitapps/parser/blob/master/src/main/java/org/mtransit/parser/gtfs/data/GRouteType.kt | ||
| TYPE=$(xmllint --xpath "//resources/integer[@name='gtfs_rts_agency_type']/text()" "$GTFS_RDS_VALUES_GEN_FILE") | ||
| elif [ -f $AGENCY_JSON_FILE ]; then | ||
|
mmathieum marked this conversation as resolved.
|
||
| # https://github.com/mtransitapps/parser/blob/master/src/main/java/org/mtransit/parser/gtfs/data/GRouteType.kt | ||
| TYPE=$(jq '.target_route_type_id // empty' "$AGENCY_JSON_FILE") | ||
| else | ||
| echo "> No agency file! (rds:$GTFS_RDS_VALUES_GEN_FILE|json:$AGENCY_JSON_FILE)" | ||
| exit 1 # error | ||
| fi | ||
| if [ -z "$TYPE" ]; then | ||
| echo " > No type found for agency!" | ||
| exit 1 # error | ||
| fi | ||
| TYPE_LABEL=""; | ||
| if [ "$TYPE" -eq 0 ]; then # LIGHT_RAIL | ||
| TYPE_LABEL="trains légers"; # TODO? | ||
| elif [ "$TYPE" -eq 1 ]; then # SUBWAY | ||
| TYPE_LABEL="métros"; | ||
| elif [ "$TYPE" -eq 2 ]; then # TRAIN | ||
| TYPE_LABEL="trains"; | ||
| elif [ "$TYPE" -eq 3 ]; then # BUS | ||
| TYPE_LABEL="autobus"; | ||
| elif [ "$TYPE" -eq 4 ]; then # FERRY | ||
| TYPE_LABEL="bateaux"; | ||
| else | ||
| echo "Unexpected agency type '$TYPE'!" | ||
| exit 1 # error | ||
| fi | ||
|
|
||
| AGENCY_TYPE_FILE="${CONFIG_DIR}/agency_type"; | ||
| if [ -f "$AGENCY_TYPE_FILE" ]; then | ||
| AGENCY_TYPE_SHORT=$(head -n 1 "$AGENCY_TYPE_FILE"); | ||
| if [ -n "$AGENCY_TYPE_SHORT" ]; then | ||
| TYPE_LABEL="$AGENCY_TYPE_SHORT"; | ||
| fi | ||
| fi | ||
|
|
||
| cat >>"${GTFS_RTS_STRINGS_FILE}" <<EOL | ||
|
mmathieum marked this conversation as resolved.
|
||
| <?xml version="1.0" encoding="utf-8"?> | ||
| <!-- DO NOT EDIT: this file is generated by MTgtfs_rts_strings.xml.MT.sh --> | ||
| <resources> | ||
| <string name="gtfs_rts_label">$AGENCY_NAME_LONG $TYPE_LABEL</string> | ||
| <string name="gtfs_rts_short_name">$AGENCY_NAME_SHORT</string> | ||
| </resources> | ||
| EOL | ||
|
|
||
| if [[ ${IS_CI} = true ]]; then | ||
| echo "---------------------------------------------------------------------------------------------------------------"; | ||
| cat "${GTFS_RTS_STRINGS_FILE}"; #DEBUG | ||
| echo "---------------------------------------------------------------------------------------------------------------"; | ||
| fi | ||
|
|
||
| echo ">> Generating values-fr/gtfs_rts_strings.xml... DONE"; | ||
|
mmathieum marked this conversation as resolved.
Outdated
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.