New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

astro-static-dict

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

astro-static-dict - npm Package Compare versions

Comparing version 1.1.0 to 1.1.1

18

client/index.js

@@ -91,19 +91,27 @@ /******************************************************************************

});
const handler = (event) => __awaiter(void 0, void 0, void 0, function* () {
const handler = (newLanguage) => __awaiter(void 0, void 0, void 0, function* () {
try {
changeLanguageOnPage({
newDict: yield getDictionary(event.detail),
newDict: yield getDictionary(newLanguage),
keySeparator,
keySuffix
});
window.selectedLanguage = event.detail;
window.selectedLanguage = newLanguage;
}
catch (error) {
console.error(`Dictionary for language ${event.detail} not found`);
console.error(`Dictionary for language ${newLanguage} not found`);
}
});
window.changeLanguage = (newLanguage) => window.dispatchEvent(new CustomEvent('changeLanguage', { detail: newLanguage }));
window.addEventListener('changeLanguage', handler);
window.addEventListener('changeLanguage', event => handler(event.detail));
document.addEventListener('astro:after-swap', () => {
if (defaultLanguage === window.selectedLanguage) {
return;
}
const selectedLanguage = window.selectedLanguage;
window.selectedLanguage = defaultLanguage;
handler(selectedLanguage);
});
};
export { watchLanguageChange };
{
"author": "brentlok",
"name": "astro-static-dict",
"version": "1.1.0",
"version": "1.1.1",
"main": "index.js",

@@ -6,0 +6,0 @@ "repository": "https://github.com/Brentlok/astro-static-dict",

@@ -88,8 +88,12 @@ # Astro static dict

```astro
<script>
import { watchLanguageChange } from 'astro-static-dict/client'
```ts
import { watchLanguageChange } from 'astro-static-dict/client'
import { enUs } from 'lib/locale'
watchLanguageChange()
</script>
watchLanguageChange({
cachedDictionaries: {
enUs
},
defaultLanguage: 'enUs'
})
```

@@ -99,8 +103,10 @@

#### watchLanguageChange config (optional)
#### watchLanguageChange config
| Property | Type | Description |
|-----------------|----------------------------|-------------------------------------------------------------------------------------------------------------------------------------------|
| keySeparator | string | Default: `@@@` <br> Must be the same as initDictionary's keySeparator |
| keySuffix | string | Default: `!!!` <br> Must be the same as initDictionary's keySuffix |
| Property | Type | Description |
|--------------------|------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------|
| cachedDictionaries | Record<string, DictionaryBranch> | Dictionaries that will be injected into window.cachedDictionaries, you must include dictionary used in build process but more is up to you |
| defaultLanguage | string | <br> Name of default language used on a page. Must be the same as dictionary used in build process |
| keySeparator | string | Default: `@@@` <br> Must be the same as initDictionary's keySeparator |
| keySuffix | string | Default: `!!!` <br> Must be the same as initDictionary's keySuffix |

@@ -116,1 +122,11 @@ #### Trigger language change

```
### Window modified properties
```ts
interface Window {
changeLanguage(newLanguage: string): void,
selectedLanguage: string,
cachedDictionaries: Partial<Record<string, DictionaryBranch>>
}
```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc