Skip to content

Commit

Permalink
Merge pull request #324 from HelloYeew/add-translation-in-code
Browse files Browse the repository at this point in the history
Internationalize string in codebase
  • Loading branch information
HelloYeew authored Apr 23, 2022
2 parents 73cf201 + d9e6a16 commit 569c3f0
Show file tree
Hide file tree
Showing 6 changed files with 450 additions and 140 deletions.
33 changes: 30 additions & 3 deletions rurusetto/users/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: 2022.410.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-09 06:04+0700\n"
"PO-Revision-Date: 2022-04-09 06:20+0700\n"
"POT-Creation-Date: 2022-04-24 00:31+0700\n"
"PO-Revision-Date: 2022-04-24 00:31+0700\n"
"Last-Translator: Phawit Pornwattanakul <[email protected]>\n"
"Language-Team: Rūrusetto <[email protected]>\n"
"Language: English\n"
Expand Down Expand Up @@ -370,7 +370,8 @@ msgstr "Site Languages"

#: .\templates\users\settings.html:191
msgid "site_languages_description"
msgstr "Settings for global site languages. (This function is under test phase)"
msgstr ""
"Settings for global site languages. (This function is under test phase)"

#: .\templates\users\settings.html:197
msgid "rulesets_creator_settings"
Expand Down Expand Up @@ -450,3 +451,29 @@ msgstr "This account is connected to osu! account with username"
#: .\templates\users\settings.html:269
msgid "delete_account_process"
msgstr "Delete Account Process"

#: .\views.py:54 .\views.py:63 .\views.py:74 .\views.py:86 .\views.py:98
msgid "Your settings has been updated!"
msgstr "Your settings has been updated!"

#: .\views.py:132
msgid "All profile and website settings are visible here!"
msgstr "All profile and website settings are visible here!"

#: .\views.py:169
#, python-format
msgid "%(username)s 's profile"
msgstr "%(username)s 's profile"

#: .\views.py:172
#, python-format
msgid "%(username)s 's profile page"
msgstr "%(username)s 's profile page"

#: .\views.py:200
msgid "Account successfully deleted."
msgstr "Account successfully deleted."

#: .\views.py:203
msgid "Delete Account failed. Please check your username and password."
msgstr "Delete Account failed. Please check your username and password."
30 changes: 28 additions & 2 deletions rurusetto/users/locale/th/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ msgid ""
msgstr ""
"Project-Id-Version: 2022.410.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-04-09 06:04+0700\n"
"PO-Revision-Date: 2022-04-09 06:20+0700\n"
"POT-Creation-Date: 2022-04-24 00:33+0700\n"
"PO-Revision-Date: 2022-04-24 00:33+0700\n"
"Last-Translator: Phawit Pornwattanakul <[email protected]>\n"
"Language-Team: Rūrusetto <[email protected]>\n"
"Language: Thai\n"
Expand Down Expand Up @@ -441,3 +441,29 @@ msgstr "บัญชีนี้ถูกเชื่อมต่อกับบ
#: .\templates\users\settings.html:269
msgid "delete_account_process"
msgstr "กระบวนการลบบัญชี"

#: .\views.py:54 .\views.py:63 .\views.py:74 .\views.py:86 .\views.py:98
msgid "Your settings has been updated!"
msgstr "การตั้งค่าของคุณได้รับการอัพเดทแล้ว!"

#: .\views.py:132
msgid "All profile and website settings are visible here!"
msgstr "การตั้งค่าโปรไฟล์และเว็ปไซต์ทั้งหมดอยู่ที่นี่!"

#: .\views.py:169
#, python-format
msgid "%(username)s 's profile"
msgstr "โปรไฟล์ของ %(username)s"

#: .\views.py:172
#, python-format
msgid "%(username)s 's profile page"
msgstr "หน้าโปรไฟล์ของ %(username)s"

#: .\views.py:200
msgid "Account successfully deleted."
msgstr "บัญชีของคุณถูกลบแล้ว"

#: .\views.py:203
msgid "Delete Account failed. Please check your username and password."
msgstr "ลบบัญชีไม่สำเร็จ กรุณาตรวจสอบชื่อผู้ใช้และรหัสผ่านของคุณ"
21 changes: 11 additions & 10 deletions rurusetto/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.templatetags.static import static
from django.contrib.auth import logout
from django.utils import translation
from django.utils.translation import gettext

from .forms import UserUpdateForm, ProfileUpdateForm, UpdateProfileEveryLoginConfigForm, UserDeleteAccountForm, \
UserThemeConfigForm, UserSubpageConfigForm, UserSupportCreatorForm, UserHideEmailConfigForm, UserLanguageConfigForm
Expand Down Expand Up @@ -50,7 +51,7 @@ def settings(request):
language_config_form.save()
support_form.save()
hide_email_config_form.save()
messages.success(request, f'Your settings has been updated!')
messages.success(request, gettext('Your settings has been updated!'))
return redirect('settings')
else:
# Nothing changed here except website config that must be save
Expand All @@ -59,7 +60,7 @@ def settings(request):
language_config_form.save()
support_form.save()
hide_email_config_form.save()
messages.success(request, f'Your settings has been updated!')
messages.success(request, gettext('Your settings has been updated!'))
return redirect('settings')
else:
if not profile_sync_form['update_profile_every_login'].value() and request.user.config.update_profile_every_login:
Expand All @@ -70,7 +71,7 @@ def settings(request):
language_config_form.save()
support_form.save()
hide_email_config_form.save()
messages.success(request, f'Your settings has been updated!')
messages.success(request, gettext('Your settings has been updated!'))
return redirect('settings')
else:
# User want to change sync config from False to True, must check on the valid of other form too.
Expand All @@ -82,7 +83,7 @@ def settings(request):
language_config_form.save()
support_form.save()
hide_email_config_form.save()
messages.success(request, f'Your settings has been updated!')
messages.success(request, gettext('Your settings has been updated!'))
return redirect('settings')
else:
# User that send request are login by normal Django login, cannot use profile sync system.
Expand All @@ -94,7 +95,7 @@ def settings(request):
language_config_form.save()
support_form.save()
hide_email_config_form.save()
messages.success(request, f'Your settings has been updated!')
messages.success(request, gettext('Your settings has been updated!'))
return redirect('settings')

else:
Expand Down Expand Up @@ -128,7 +129,7 @@ def settings(request):
'osu_confirm_username': osu_confirm_username,
'hero_image': static(hero_image),
'hero_image_light': static(hero_image_light),
'opengraph_description': 'All profile and website settings are visible here!',
'opengraph_description': gettext('All profile and website settings are visible here!'),
'opengraph_url': resolve_url('settings'),
}
if request.user.is_authenticated:
Expand Down Expand Up @@ -165,10 +166,10 @@ def profile_detail(request, pk):
'tag_list': tag_object_list,
'hide_email': config_object.hide_email,
'created_ruleset': fetch_created_ruleset(profile_object.id),
'title': f"{profile_object.user.username}'s profile",
'title': gettext(f"%(username)s 's profile") % {'username': profile_object.user.username},
'hero_image': profile_object.cover.url,
'hero_image_light': profile_object.cover_light.url,
'opengraph_description': f"{profile_object.user.username}'s profile page",
'opengraph_description': gettext(f"%(username)s 's profile page") % {'username': profile_object.user.username},
'opengraph_url': resolve_url('profile', pk=profile_object.user.id),
'opengraph_image': profile_object.cover.url
}
Expand Down Expand Up @@ -196,10 +197,10 @@ def delete_account(request):
# Delete user (and any associated ForeignKeys, according to
# on_delete parameters).
user.delete()
messages.success(request, 'Account successfully deleted.')
messages.success(request, gettext('Account successfully deleted.'))
return redirect('home')
else:
messages.error(request, f'Delete Account failed. Please check your username and password.')
messages.error(request, gettext(f'Delete Account failed. Please check your username and password.'))
return redirect('settings')
else:
account_delete_form = UserDeleteAccountForm()
Expand Down
Loading

0 comments on commit 569c3f0

Please sign in to comment.