question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Framework Request] Support a Mozilla webextension format

See original GitHub issue

What framework do you want to have? Please provide links of its i18n solution/package. I’m using react-intl but with as custom converter method to support mozilla webextension format instead of plain json. image

This has the advantage to add “descriptions” for every translation used by weblate translators. I added a custom framework definition which seems to work because the keys on my code are properly detected: image

But ally seems not to be able to match the detected key to the localization files (I guess because of the sub-structure): image

So my localization works like uses i18n with the exception that I don’t have simple key-value pairs in my json file. I’m using the WebExtension format:

"carport_mainComplaint": {
    "message": "Main Complaint"
  },

the before setting i18n to use the json files I conveert those object to the usual format:

type ObjStringProps = { [key: string]: string };
// eslint-disable-next-line @typescript-eslint/no-explicit-any
export function convertWebExtensionFormatToI18n(jsonObj: any): ObjStringProps {
  const result = { default: '' } as ObjStringProps; //default is always part of an object, so create it here explicitly to be TSC compatible
  for (const prop in jsonObj) {
    result[prop] = jsonObj[prop].message as string;
  }
  delete result.default;
  return result;
}

How do I need to define an ally custom framework to support this mapping?

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
hbinklecommented, Jul 26, 2021

Hi, thanks to @antfu I got it to work meanwhile. Defining refactorTemplates with the used method and turning off monopoly works:

[...]
refactorTemplates:
  - translate("$1")

# If set to true, only enables this custom framework (will disable all built-in frameworks)
monopoly: false
0reactions
stale[bot]commented, Jul 17, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

webRequest - MDN Web Docs - Mozilla
Chrome Edge BlockingResponse Full support. ChromeYes. Toggle history Full... BlockingResponse.upgradeToSecure No support. ChromeNo. Toggle history No s... CertificateInfo No support. ChromeNo. footnote. Toggle history No s......
Read more >
Example extensions - Mozilla - MDN Web Docs
Name Description JavaScript APIs dynamic‑theme Dynamic theme example alarms.create · alarms.onAlarm · them... emoji‑substitution Replaces words with emojis. top‑sites Demonstration of the topSites API. topSites.get
Read more >
API Implementation Basics - Firefox Source Docs
The WebExtensions framework reads this schema and takes care of injecting the right objects into each extension Javascript environment.
Read more >
Browser Extensions - Mozilla - MDN Web Docs
Extensions, or add-ons, can modify and enhance the capability of a browser. Extensions for Firefox are built using the WebExtensions API ...
Read more >
Anatomy of an extension - Mozilla - MDN Web Docs
The components of a web extension. The manifest.JSON must be present in all. See the manifest.json reference page for all the details. Along ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found