Skip to content

Commit

Permalink
adding context to strings in order to obtain more accurate translations
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier Manrique committed Nov 23, 2024
1 parent 933f39d commit 9fd2ae2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,34 @@
<resources>
<string name="loading_lottie_path" translatable="false">files/loading-lottie.json</string>
<string name="loading_content_description">Lottie loading animation</string>
<string name="onboarding_button_text">GET STARTED</string>
<string name="non_parked_screen_title">Nice to see you</string>
<string name="onboarding_button_text" comment="Start doing something">GET STARTED</string>
<string name="non_parked_screen_title" comment="Title text without final period">Nice to see you</string>
<string name="non_parked_screen_title_icon_content_description">Title</string>
<string name="non_parked_screen_refresh_icon_content_description">Refresh</string>
<string name="non_parked_screen_close_button_content_description">Close</string>
<string name="non_parked_screen_lottie_path" translatable="false">files/car-lottie.json</string>
<string name="non_parked_screen_lottie_content_description">Lottie animation</string>
<string name="non_parked_screen_detail_placeholder">Take a note</string>
<string name="non_parked_screen_camera_button_content_description">Camera</string>
<string name="non_parked_screen_park_button">PARK</string>
<string name="non_parked_screen_park_button" comment="Vehicle parking button">PARK</string>
<string name="non_parked_screen_animated_text_1">Storing your parking location</string>
<string name="non_parked_screen_animated_text_2">Scanning for UFOs...</string>
<string name="non_parked_screen_animated_text_3">Nope, just your car</string>
<string name="non_parked_screen_animated_text_4">Mapping the way back to your ride...</string>
<string name="non_parked_screen_animated_text_5">Compass calibrated. You’ll never get lost!</string>
<string name="non_parked_screen_animated_text_6">Where is my car?</string>
<string name="parked_screen_stop_parking_dialog_title">Confirmation</string>
<string name="parked_screen_stop_parking_dialog_title" comment="Confirmation title">Confirmation</string>
<string name="parked_screen_stop_parking_dialog_body">Are you sure you want to stop parking?</string>
<string name="parked_screen_stop_parking_dialog_positive_action">Accept</string>
<string name="parked_screen_stop_parking_dialog_negative_action">Cancel</string>
<string name="parked_screen_title">You are parked</string>
<string name="parked_screen_stop_parking_dialog_positive_action" comment="Accept button">Accept</string>
<string name="parked_screen_stop_parking_dialog_negative_action" comment="Cancel button">Cancel</string>
<string name="parked_screen_title" comment="You have parked your vehicle">You are parked</string>
<string name="parked_screen_title_image_description">Emoji</string>
<string name="parked_screen_map_icon_content_description">Map</string>
<string name="parked_screen_eye_icon_content_description">Eye</string>
<string name="parked_screen_forward_icon_content_description">Forward</string>
<string name="parked_screen_forward_icon_content_description" comment="Forward synonym of sending">Forward</string>
<string name="parked_screen_address_title">Here is your vehicle</string>
<string name="parked_screen_lottie_path">files/location-pin-lottie.json</string>
<string name="parked_screen_lottie_path" translatable="false">files/location-pin-lottie.json</string>
<string name="parked_screen_date_title">Since</string>
<string name="parked_screen_detail_title">You got a note</string>
<string name="parked_screen_stop_parking_button">STOP PARKING</string>
<string name="parked_screen_stop_parking_button" comment="Stop vehicle parking">stop parking</string>
</resources>
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ fun ParkedScreen(
) {
Text(
modifier = Modifier.padding(vertical = 8.dp),
text = stringResource(uiState.stopParkingButtonText),
text = stringResource(uiState.stopParkingButtonText).uppercase(),
color = Color.Black,
fontWeight = FontWeight.ExtraBold
)
Expand Down
3 changes: 3 additions & 0 deletions translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,16 @@ def create_directories(dir_language):
for i in range(len(root)):
if 'translatable' not in root[i].attrib:
value = root[i].text
context = root[i].comment
if value is not None:
params = {
'auth_key' : API_KEY,
'text' : value,
'source_lang' : languages_from_translate,
"target_lang": language_to_translate
}
if context is not None:
params['context'] = context
request = requests.post("https://api.deepl.com/v2/translate", data=params)
result = request.json()

Expand Down

0 comments on commit 9fd2ae2

Please sign in to comment.