Skip to content
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

✨ [Story localization] Fetch strings for localization files if in experiment #37843

Merged
merged 36 commits into from
Mar 17, 2022

Conversation

mszylkowski
Copy link
Contributor

@mszylkowski mszylkowski commented Mar 9, 2022

Create experiment story-remote-localization that disables the localization strings from the bundle and relies on the remote strings (from the CDN or localhost). The story first tries to find inline strings, and if not found, it will either install the strings bundled into amp-story or it will fetch from the CDN or localhost (depending on localDev)

Strings can be from:

Note: if the language is not one of the 80+ languages accepted, we will deal with that in the cache. Locally it will fail, but should not happen for any demo files.

dist/v0/amp-story-0.1.mjs: Δ +0.14KB
dist/v0/amp-story-1.0.mjs: Δ +0.14KB
dist/v0/amp-story-0.1.js: Δ +0.15KB
dist/v0/amp-story-1.0.js: Δ +0.15KB

cc @erwinmombay

mszylkowski and others added 29 commits December 21, 2021 14:45
Co-authored-by: Gabriel Majoulet <[email protected]>
@mszylkowski mszylkowski changed the title [Draft] Test fetchstrings controlled ✨ [Story localization] Fetch strings for localization files if in experiment Mar 10, 2022
@mszylkowski mszylkowski marked this pull request as ready for review March 10, 2022 21:17
@amp-owners-bot amp-owners-bot bot requested a review from samouri March 10, 2022 21:17
@amp-owners-bot
Copy link

Hey @gmajoulet, @newmuis! These files were changed:

extensions/amp-story/1.0/amp-story.js
extensions/amp-story/1.0/test/test-amp-story.js

@mszylkowski mszylkowski removed the request for review from samouri March 10, 2022 21:19
extensions/amp-story/1.0/amp-story.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/amp-story.js Show resolved Hide resolved
extensions/amp-story/1.0/amp-story.js Show resolved Hide resolved
extensions/amp-story/1.0/amp-story.js Show resolved Hide resolved
extensions/amp-story/1.0/amp-story.js Show resolved Hide resolved
extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
Copy link
Contributor Author

@mszylkowski mszylkowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed all comments, ready for another look @gmajoulet

extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
@@ -1709,6 +1709,77 @@ describes.realWin(
'Swipe up'
);
});

describe('remote locales', () => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code overall doesn't seem to be extremely consistent but will try with this PR to keep all the changes using localization.

extensions/amp-story/1.0/test/test-amp-story.js Outdated Show resolved Hide resolved
extensions/amp-story/1.0/amp-story.js Outdated Show resolved Hide resolved
.then((json) =>
localizationService.registerLocalizedStringBundle(languageCode, json)
)
.catch((err) => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We shouldn't launch this till the AMP Cache does this fallback then, otherwise all docs with wrong lang parameters would start failing.

@mszylkowski mszylkowski requested review from caroqliu and samouri and removed request for caroqliu March 17, 2022 14:18
@mszylkowski
Copy link
Contributor Author

@samouri we need OWNERS approval to add a prerenderSafe request that fetches a JSON from the AMP cache. Do you need any more details on this? Request will be to https://cdn.ampproject.org/v0/amp-story.en.json but en can be replaced with other languages (eg: es) to fetch the localization strings.

@mszylkowski mszylkowski merged commit 32ea192 into ampproject:main Mar 17, 2022
@mszylkowski mszylkowski deleted the TEST_fetchstrings_controlled branch March 17, 2022 18:44
@ampprojectbot
Copy link
Member

Warning: disparity between this PR Percy build and its main build

The Percy build for this PR was approved (either manually by a member of the AMP team, or automatically if there were no visual diffs). However, during a continuous integration step we generated another Percy build using the commit on the main branch that this PR was merged into, and there appears to be a mismatch between the two.

This is possibly an indication of an issue with this pull request, but could also be the result of flakiness. Please inspect the two builds < This PR's Percy build / main commit's Percy build > and determine further action:

  • If the disparity appears to be caused by this PR, please create an bug report or send out a new PR to fix
  • If the disparity appears to be a flake, please @-mention ampproject/wg-approvers in a comment
  • If there is no disparity and this comment was created by mistake, please @-mention ampproject/wg-infra
  • If unsure, @-mention ampproject/wg-approvers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants