Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@transifex/native

Package Overview
Dependencies
Maintainers
1
Versions
94
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@transifex/native - npm Package Compare versions

Comparing version 1.0.5 to 2.0.0-rc1

8

package.json
{
"name": "@transifex/native",
"version": "1.0.5",
"version": "2.0.0-rc1",
"description": "Transifex Native for Javascript",

@@ -31,3 +31,3 @@ "keywords": [

"engines": {
"node": ">=10.0.0"
"node": ">=12.0.0"
},

@@ -47,3 +47,3 @@ "devDependencies": {

"glob": "^7.1.7",
"mocha": "^8.4.0",
"mocha": "^9.1.3",
"nock": "^13.1.0",

@@ -57,5 +57,5 @@ "nyc": "^15.1.0",

"@messageformat/core": "^3.0.0",
"axios": "^0.21.1",
"axios": "^0.24.0",
"md5": "^2.3.0"
}
}

@@ -7,3 +7,3 @@ # Transifex Native for Javascript

Supported Node.js versions >= `10.x.x`
Supported Node.js versions >= `12.x.x`

@@ -14,4 +14,8 @@ Related packages:

## Quick starting guide
# Upgrade to v2
If you are upgrading from the `1.x.x` version, please read this [migration guide](https://github.com/transifex/transifex-javascript/blob/HEAD/UPGRADE_TO_V2.md), as there are breaking changes in place.
# Quick starting guide
Install the library using:

@@ -21,3 +25,3 @@

### Webpack
## Webpack

@@ -58,3 +62,3 @@ ```js

### Node.js
## Node.js

@@ -72,3 +76,3 @@ ```js

### Browser
## Browser

@@ -96,5 +100,5 @@ ```html

## API
# API
#### Initialize library
## Initialize library

@@ -126,3 +130,3 @@ ```js

### Languages
## Languages

@@ -154,3 +158,3 @@ Fetches list of project languages from CDS, useful for creating a language picker.

#### Set current translation language
### Set current translation language

@@ -169,3 +173,3 @@ Fetches translations from the CDS and stores them in cache. When the

#### Get current translation language
### Get current translation language

@@ -181,3 +185,3 @@ Returns the currently selected language code.

### Content translation
## Content translation

@@ -225,3 +229,3 @@ Returns the translation of the passed source string based on the

### Escaping translations
## Escaping translations

@@ -231,3 +235,3 @@ Using the translation as is from the `t` function inside HTML is dangerous for

#### Escaping text translations
### Escaping text translations

@@ -241,3 +245,3 @@ ```js

#### Escaping HTML source
### Escaping HTML source

@@ -256,3 +260,3 @@ HTML source content cannot be globally escaped. In that case, we can just escape

### Events
## Events

@@ -259,0 +263,0 @@ Library for listening to various async events.

@@ -9,3 +9,3 @@ /* globals __VERSION__, __PLATFORM__ */

import {
generateKey, isString, isPluralized, escape,
generateKey, isString, isPluralized, escape, generateHashedKey,
} from './utils';

@@ -101,7 +101,20 @@ import {

try {
const pluralized = isPluralized(sourceString);
const key = generateKey(sourceString, params);
let translation = this.cache.get(key, locale);
// get translation from source based key (2.x.x)
let translation = this.cache.get(
generateKey(sourceString, params),
locale,
);
if (translation && pluralized && translation.startsWith('{???')) {
// fall back to hash based key (1.x.x)
if (!translation) {
translation = this.cache.get(
generateHashedKey(sourceString, params),
locale,
);
}
if (translation
&& translation.startsWith('{???')
&& isPluralized(sourceString)
) {
const variableName = sourceString

@@ -108,0 +121,0 @@ .substring(1, sourceString.indexOf(','))

@@ -14,2 +14,21 @@ import md5 from 'md5';

if (options._context) {
return `${string}::${options._context}`;
}
// ensure string is returned
return `${string}`;
}
/**
* Generate a hashed based string key
*
* @export
* @param {String} string
* @param {Object} options
* @returns {String} key
*/
export function generateHashedKey(string, options = {}) {
if (options._key) return options._key;
let context = '';

@@ -16,0 +35,0 @@ if (options._context) {

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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