-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
[i18n] Load "en" translations parallely #3102
Merged
Merged
Changes from 13 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
b0ab693
load en translations in parallel
rajatvijay 855da7b
Merge branch 'develop' of github.com:centerofci/mathesar into i18n-lo…
rajatvijay 1738aca
renamed loadTranslationsIntoMemory to loadTranslations
rajatvijay b5c5bde
made translations script async
rajatvijay 9b1c64c
Merge branch 'develop' into i18n-load-en-translations-parallely
rajatvijay 42830ff
move translations path logic to context processor
rajatvijay 8b22c87
use loadAsyncLocale to let vite bundle it as default exported module
rajatvijay c5ed4bc
lint fixes
rajatvijay 25c89ce
do not read legacy builds for translations files
rajatvijay 43243d3
Merge branch 'develop' into i18n-load-en-translations-parallely
rajatvijay 737effa
render page when loading default lang translations
rajatvijay a9235ab
Merge branch 'i18n-load-en-translations-parallely' of github.com:cent…
rajatvijay 01a4b4e
Merge branch 'develop' into i18n-load-en-translations-parallely
pavish 6c5a54d
Merge branch 'develop' of github.com:centerofci/mathesar into i18n-lo…
rajatvijay 2d99656
Merge branch 'develop' of github.com:centerofci/mathesar into i18n-lo…
rajatvijay b11f2b0
move window.Mathesar.translations init in translations file
rajatvijay e17a308
removed import with explicit extensions
rajatvijay 6c50c83
moved i18n cache to i18n-store file from utils
rajatvijay e30a065
read new translations format in App.svelte
rajatvijay File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
@@ -1,17 +1,50 @@ | ||
from django.conf import settings | ||
from django.templatetags.static import static | ||
|
||
|
||
from mathesar.utils.frontend import get_manifest_data | ||
|
||
|
||
def frontend_settings(request): | ||
manifest_data = get_manifest_data() | ||
development_mode = settings.MATHESAR_MODE == 'DEVELOPMENT' | ||
|
||
i18n_settings = get_i18n_settings(manifest_data, development_mode) | ||
frontend_settings = { | ||
'development_mode': settings.MATHESAR_MODE == 'DEVELOPMENT', | ||
'manifest_data': get_manifest_data(), | ||
'development_mode': development_mode, | ||
'manifest_data': manifest_data, | ||
'live_demo_mode': getattr(settings, 'MATHESAR_LIVE_DEMO', False), | ||
'live_demo_username': getattr(settings, 'MATHESAR_LIVE_DEMO_USERNAME', None), | ||
'live_demo_password': getattr(settings, 'MATHESAR_LIVE_DEMO_PASSWORD', None), | ||
**i18n_settings | ||
} | ||
# Only include development URL if we're in development mode. | ||
if frontend_settings['development_mode'] is True: | ||
frontend_settings['client_dev_url'] = settings.MATHESAR_CLIENT_DEV_URL | ||
|
||
return frontend_settings | ||
|
||
|
||
def get_i18n_settings(manifest_data, development_mode): | ||
""" | ||
Hard coding this for now | ||
but will be taken from users model | ||
and cookies later on | ||
""" | ||
preferred_language = 'en' | ||
default_language = 'en' | ||
|
||
client_dev_url = settings.MATHESAR_CLIENT_DEV_URL | ||
|
||
if development_mode is True: | ||
module_translations_file_path = f'{client_dev_url}/src/i18n/{preferred_language}/index.ts' | ||
else: | ||
try: | ||
module_translations_file_path = static(manifest_data[preferred_language]["file"]) | ||
except KeyError: | ||
module_translations_file_path = static(manifest_data[default_language]["file"]) | ||
|
||
return { | ||
'module_translations_file_path': module_translations_file_path, | ||
'preferred_language': preferred_language | ||
} |
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
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
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
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
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
from @seancolsen - adding a comment here explaining "why this approach?" since this approach is weird.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added