Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shared-modules/MTREADME.md.MT.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ fi

AGENCY_LABEL=$AGENCY_NAME_LONG;

if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
AGENCY_LABEL="$AGENCY_LOCATION_SHORT $AGENCY_LABEL"
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ if [ -f "$PARENT_AGENCY_NAME_FILE" ]; then
fi
fi

if [ -n "$AGENCY_LOCATION_SHORT" ]; then
AGENCY_LABEL="$AGENCY_LOCATION_SHORT $AGENCY_LABEL"
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
AGENCY_LABEL="$AGENCY_LOCATION_SHORT $AGENCY_LABEL";
fi

GIT_OWNER="mtransitapps"; #TODO extract from GIT_REMOTE_URL=$(git config --get remote.origin.url); # 'git@github.com:owner/repo.git' or 'https://github.com/owner/repo'.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ if [ -f "$AGENCY_TYPE_FILE" ]; then
fi

AGENCY_LABEL=$AGENCY_NAME_SHORT;
if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
AGENCY_LABEL="$AGENCY_LOCATION_SHORT $AGENCY_LABEL"
fi

Expand Down Expand Up @@ -149,6 +149,10 @@ if [ -f "${GTFS_RT_FILE}" ]; then
fi
fi
fi
STM_INFO_VALUES_FILE="${VALUES_DIR}/stm_info_values.xml";
if [ -f "${STM_INFO_VALUES_FILE}" ]; then
SHORT_DESC="${SHORT_DESC} Service Updates.";
fi
# TODO: support other real-time providers

RSS_FILE="${VALUES_DIR}/rss_values.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ AGENCY_LABEL=$AGENCY_NAME_SHORT;

AGENCY_LABEL_AND_LOCATION_SHORT_LENGTH=$((${#AGENCY_LABEL} + ${#AGENCY_LOCATION_SHORT} + $TYPE_LABEL_MIN_LENGTH));

if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL_AND_LOCATION_SHORT_LENGTH" -lt "$MAX_LENGTH" ]]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* && "$AGENCY_LABEL_AND_LOCATION_SHORT_LENGTH" -lt "$MAX_LENGTH" ]]; then
AGENCY_LABEL="$AGENCY_LOCATION_SHORT $AGENCY_LABEL"
fi

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if [ -f "$PARENT_AGENCY_NAME_FILE" ]; then
fi
fi

if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
AGENCY_LABEL="$AGENCY_LABEL de $AGENCY_LOCATION_SHORT"
fi

Expand Down Expand Up @@ -226,7 +226,7 @@ if [ -z "$TYPE" ]; then
fi
TYPE_LABEL="";
if [ "$TYPE" -eq 0 ]; then # LIGHT_RAIL
TYPE_LABEL="trains léger"; # TODO?
TYPE_LABEL="trains légers"; # TODO?
elif [ "$TYPE" -eq 1 ]; then # SUBWAY
TYPE_LABEL="métros";
elif [ "$TYPE" -eq 2 ]; then # TRAIN
Expand Down Expand Up @@ -255,7 +255,7 @@ if [ -f "$BIKE_STATION_VALUES_FILE" ]; then
fi
GTFS_RDS_VALUES_FILE="${VALUES_DIR}/gtfs_rts_values.xml"; # do not change to avoid breaking compat w/ old modules
if [ -f "$GTFS_RDS_VALUES_FILE" ]; then
PROVIDES_LINE="${PROVIDES_LINE} les horaires (accessible hors-ligne)";
PROVIDES_LINE="${PROVIDES_LINE} l'horaire (accessible hors-ligne)";
if [ -n "$INFORMATION_LIST" ]; then
INFORMATION_LIST="${INFORMATION_LIST},";
fi
Expand Down Expand Up @@ -384,7 +384,7 @@ Cette application ajoute les informations des $TYPE_LABEL $AGENCY_LABEL à MonTr

$PROVIDES_LINE.

Les $TYPE_LABEL de $AGENCY_NAME_SHORT $OPERATE_IN $LOCATION_LABEL.
Les $TYPE_LABEL $AGENCY_NAME_SHORT $OPERATE_IN $LOCATION_LABEL.

Une fois cette application installée, l'application MonTransit affichera les informations des $TYPE_LABEL ($INFORMATION_LIST...).

Expand All @@ -398,7 +398,7 @@ $SOURCE_URL
Cette application est gratuite et open-source :
$CONTACT_WEBSITE_URL

Cette application n'est pas associée à $NOT_RELATED_WITH.
Cette application n'est pas associée à : $NOT_RELATED_WITH.
EOL

PERMISSIONS_LINE="";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ else
fi

AGENCY_LABEL=$AGENCY_NAME_SHORT;
if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
AGENCY_LABEL="$AGENCY_LABEL de $AGENCY_LOCATION_SHORT"
fi

Expand Down Expand Up @@ -151,6 +151,10 @@ if [ -f "${GTFS_RT_FILE}" ]; then
fi
fi
fi
STM_INFO_VALUES_FILE="${VALUES_DIR}/stm_info_values.xml";
if [ -f "${STM_INFO_VALUES_FILE}" ]; then
SHORT_DESC="${SHORT_DESC} État de service.";
fi
# TODO: support other real-time providers

RSS_FILE="${VALUES_DIR}/rss_values.xml";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ AGENCY_LABEL=$AGENCY_NAME_SHORT;

AGENCY_LABEL_AND_LOCATION_SHORT_LENGTH=$((${#AGENCY_LABEL} + ${#AGENCY_LOCATION_SHORT}));

if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL_AND_LOCATION_SHORT_LENGTH" -lt "$MAX_LENGTH" ]]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* && "$AGENCY_LABEL_AND_LOCATION_SHORT_LENGTH" -lt "$MAX_LENGTH" ]]; then
AGENCY_LABEL="$AGENCY_LABEL $AGENCY_LOCATION_SHORT"
fi

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash
SCRIPT_DIR="$(dirname "$0")";

ROOT_DIR="$SCRIPT_DIR/../../../../../../..";
COMMONS_DIR="${ROOT_DIR}/commons";
source ${COMMONS_DIR}/commons.sh;

setGitProjectName;

setIsCI;

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
Comment thread
mmathieum marked this conversation as resolved.
if [ ! -f "${GTFS_RDS_VALUES_FILE}" ]; then
echo ">> Generating values-fr/gtfs_rts_strings.xml... SKIP (not an rds agency)";
Comment thread
mmathieum marked this conversation as resolved.
exit 0; # ok
fi

echo ">> Generating values-fr/gtfs_rts_strings.xml...";

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";
GTFS_RTS_STRINGS_FILE="${VALUES_FR_DIR}/gtfs_rts_strings.xml";
mkdir -p "${VALUES_FR_DIR}";
checkResult $?;
Comment thread
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 $?;
Comment thread
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}/agency_name";
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
Comment thread
mmathieum marked this conversation as resolved.
Outdated

requireCommand "xmllint" "libxml2-utils";
requireCommand "jq";

GTFS_CONFIG_DIR="${CONFIG_DIR}/gtfs";
GTFS_RDS_VALUES_GEN_FILE="${VALUES_DIR}/gtfs_rts_values_gen.xml"; # do not change to avoid breaking compat w/ old modules
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
Comment thread
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
Comment thread
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";
Comment thread
mmathieum marked this conversation as resolved.
Outdated
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ if [ -z "$TYPE" ]; then
fi
TYPE_LABEL="";
if [ "$TYPE" -eq 0 ]; then # LIGHT_RAIL
TYPE_LABEL="trains léger"; # TODO?
TYPE_LABEL="trains légers"; # TODO?
elif [ "$TYPE" -eq 1 ]; then # SUBWAY
TYPE_LABEL="métros";
elif [ "$TYPE" -eq 2 ]; then # TRAIN
Expand Down Expand Up @@ -135,7 +135,7 @@ else
fi

LOCATION_LABEL="";
if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
Comment thread
mmathieum marked this conversation as resolved.
Outdated
LOCATION_LABEL="$AGENCY_LOCATION_SHORT";
elif [ -n "$STATE_LABEL_LONG" ]; then
LOCATION_LABEL="$STATE_LABEL_LONG";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ else
fi

LOCATION_LABEL="";
if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
Comment thread
mmathieum marked this conversation as resolved.
Outdated
LOCATION_LABEL="$AGENCY_LOCATION_SHORT";
elif [ -n "$STATE_LABEL_LONG" ]; then
LOCATION_LABEL="$STATE_LABEL_LONG";
Expand Down
2 changes: 1 addition & 1 deletion shared-modules/gh_repo_update_details.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fi

AGENCY_LABEL=$AGENCY_NAME_LONG;

if [ -n "$AGENCY_LOCATION_SHORT" ]; then
if [[ -n "$AGENCY_LOCATION_SHORT" && "$AGENCY_LABEL" != *"$AGENCY_LOCATION_SHORT"* ]]; then
AGENCY_LABEL="$AGENCY_LOCATION_SHORT $AGENCY_LABEL"
fi

Expand Down
1 change: 1 addition & 0 deletions shared/app-android/MT.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ proguard/
/src/main/res/values/module_app_icon_color.xml
/src/main/res/values/parent_agency_values.xml
/src/main/res/values-fr/bike_station_strings.xml
/src/main/res/values-fr/gtfs_rts_strings.xml
/src/main/res/values-fr/strings.xml

# trigger change 1
Expand Down