-
Notifications
You must be signed in to change notification settings - Fork 117
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
VPN-6749: Fix shared addon ids #10065
Changes from 4 commits
7045e3a
9639a66
e7b8256
b6affa1
3334b5d
c804db1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,18 +152,19 @@ If you want to implement new add-ons, you need to follow these steps: | |
|
||
1. Create a manifest in a separate folder in the `addons` directory of the mozilla VPN repository. | ||
2. Read and follow the documentation for the add-on type you want to implement. | ||
3. Build the CMake project in the `addons` directory. | ||
3. If new shared strings were added, process them so that strings are shown in the addon: `python ./scripts/utils/generate_shared_addon_xliff.py -i ./addons/strings.yaml -o ./3rdparty/i18n/en/addons/strings.xliff` (This step is not necessary, strictly speaking. This script is what will be run as new strings are ingested into l10n repo, and once the new strings have done a round trip to the l10n repo and then back to the client repo, the string will show up in the addon as expected. Manually running this script as part of the build process prevents the brand new addon from showing "vpn.newStringCategory.newString" until this round trip happens.) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: could you please split this line and keep the file under 100-ish characters wide? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, done |
||
4. Build the CMake project in the `addons` directory. | ||
|
||
``` | ||
mkdir -p build-addons/ | ||
cmake -S <source>/addons -B build-addons -GNinja | ||
cmake --build build-addons | ||
``` | ||
|
||
4. Expose the generated build directory through a webservice. For example: `python3 -m http.server --directory build-addons/` | ||
5. Open the dev-menu from the get-help view and set a custom add-on URL: `http://localhost:8000/` | ||
6. Scroll down and disable the signature-addon feature from the dev-menu, list of features | ||
7. Be sure you are doing all of this using a staging environment | ||
5. Expose the generated build directory through a webservice. For example: `python3 -m http.server --directory build-addons/` | ||
6. Open the dev-menu from the get-help view and set a custom add-on URL: `http://localhost:8000/` | ||
7. Scroll down and disable the signature-addon feature from the dev-menu, list of features | ||
8. Be sure you are doing all of this using a staging environment | ||
|
||
If all has done correctly, you can see the app fetching the manifest.json (and | ||
not! the manifest.json.sig) resource from the webservice. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,6 +28,16 @@ def prune_lists_to_strings(data): | |
sys.exit("Unexpected input") | ||
return data | ||
|
||
def use_proper_id(data): | ||
return_data = {} | ||
for value in data.values(): | ||
string_id = value["string_id"] | ||
return_data[string_id] = { | ||
"value": value["value"], | ||
"comments": value["comments"] | ||
} | ||
return return_data | ||
|
||
# Make sure we have all the required things | ||
# Lookup our required tools for addon generation. | ||
|
||
|
@@ -59,6 +69,8 @@ def prune_lists_to_strings(data): | |
print("First, pull in the strings from the YAML file") | ||
translation_strings = parseYAMLTranslationStrings(args.infile) | ||
translation_strings = prune_lists_to_strings(translation_strings) | ||
# parseYAMLTranslationStrings gives a different ID than we want to use | ||
translation_strings = use_proper_id(translation_strings) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of regenerating, have you considered changing diff --git a/scripts/shared.py b/scripts/shared.py
index 46ea19700..5b6222561 100644
--- a/scripts/shared.py
+++ b/scripts/shared.py
@@ -2,7 +2,7 @@ import os
import sys
import xml.etree.ElementTree as ET
-def write_en_language(filename, strings):
+def write_en_language(filename, strings, key_as_id=True):
ts = ET.Element("TS")
ts.set("version", "2.1")
ts.set("language", "en")
@@ -11,8 +11,9 @@ def write_en_language(filename, strings):
ET.SubElement(context, "name")
for key, value in strings.items():
+ id = key if key_as_id else value["string_id"]
message = ET.SubElement(context, "message")
- message.set("id", key)
+ message.set("id", id)
location = ET.SubElement(message, "location")
location.set("filename", "addon.qml")
diff --git a/scripts/utils/generate_shared_addon_xliff.py b/scripts/utils/generate_shared_addon_xliff.py
index 56efdc486..39b2f91e2 100644
--- a/scripts/utils/generate_shared_addon_xliff.py
+++ b/scripts/utils/generate_shared_addon_xliff.py
@@ -28,16 +28,6 @@ def prune_lists_to_strings(data):
sys.exit("Unexpected input")
return data
-def use_proper_id(data):
- return_data = {}
- for value in data.values():
- string_id = value["string_id"]
- return_data[string_id] = {
- "value": value["value"],
- "comments": value["comments"]
- }
- return return_data
-
# Make sure we have all the required things
# Lookup our required tools for addon generation.
@@ -69,13 +59,11 @@ print("Preparing the addons shared string file")
print("First, pull in the strings from the YAML file")
translation_strings = parseYAMLTranslationStrings(args.infile)
translation_strings = prune_lists_to_strings(translation_strings)
-# parseYAMLTranslationStrings gives a different ID than we want to use
-translation_strings = use_proper_id(translation_strings)
print("Then, write the strings to a .ts file")
tmp_path = tempfile.mkdtemp()
ts_file = os.path.join(tmp_path, "sharedAddonsStrings.ts")
-write_en_language(ts_file, translation_strings)
+write_en_language(ts_file, translation_strings, key_as_id=False)
print("Finally, convert the ts file into an xliff file")
os.system(f"{lconvert} -if ts -i {ts_file} -of xlf -o {args.outfile}") There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call, thanks. I've updated this. |
||
|
||
print("Then, write the strings to a .ts file") | ||
tmp_path = tempfile.mkdtemp() | ||
|
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.
You can exit directly with the message (across the file).
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.
I had it that way initially, but moved to
print
combined withsys.exit(1)
to match the style in the rest of this file.