
Product
Introducing Pull Request Stories to Help Security Teams Track Supply Chain Risks
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.
google-sheet-languages-model-2
Advanced tools
# Google Sheet Languages Model - i18n google sheet layer
google-sheet-languages-model-2 is a npm package that allows you to download/upload and parse internationalization (i18n) data between a Google Sheet and your local environment. This readme provides instructions on how to set up and use the google-sheet-languages-model-2 package to manage your i18n data.
Install the package using npm:
yarn add -D google-sheet-languages-model-2 googleapis
It's recommended to use the Service Account auth option to interact with the Google Sheets API. Follow these steps to set up the authorization:
credentials.json file which is generated from the Service Account and place it in your project directory.client_email field inside the credentials.json file.Firstly, import the necessary modules from the package and your configuration:
import { GoogleSheetLanguagesModel } from "google-sheet-languages-model-2";
import { SHEET_ID, languages, auth, folderPath } from "./config.ts";
Here is an example of how to download and parse i18n data from a Google Sheet and save it to a local folder:
const googleSheetLanguagesModel = new GoogleSheetLanguagesModel({
sheetId: SHEET_ID,
auth,
});
const languagesModel = await googleSheetLanguagesModel.loadFromGoogleSheet(
"Test",
languages
);
languagesModel.saveToFolder(folderPath, "nest");
console.log("pull done");
Here is an example of how to upload i18n data from a local folder to a Google Sheet:
const languagesModel = GoogleSheetLanguagesModel.loadFromFolder(
folderPath,
languages
);
const googleSheetLanguagesModel = new GoogleSheetLanguagesModel({
sheetId: SHEET_ID,
auth,
});
await googleSheetLanguagesModel.saveToGoogleSheet("Test", languagesModel);
console.log("push done");
Your config.ts should export the following variables:
SHEET_ID: The ID of your Google Sheet.languages: An array of language codes (e.g., ['en', 'es', 'fr']).auth: Your authorization credentials.folderPath: The path to the folder where you want to save or load the language files.The main classes and methods are documented in the source code provided. This will guide you on the data structures and the methods available for use.
Feel free to explore the provided code to better understand how to work with the google-sheet-languages-model-2 package to manage your i18n data.
The google-sheet-languages-model-2 package supports two different structures to describe i18n file data: nest (JS object style) and flat (key annotation style). Both styles serve to organize your internationalization data in a manner that best suits your project's needs.
In the nest structure, i18n data is organized in a nested JavaScript object format, where each key represents a nesting level. This structure is intuitive and easy to navigate, making it a good choice for projects with a hierarchical data organization.
Example:
{
"user": {
"name": "Name",
"age": "Age"
},
"messages": {
"welcome": "Welcome"
}
}
The flat structure, on the other hand, uses a single-level object with keys representing the path to the value in a dot notation. This structure is simple and often preferred in projects with a flat data organization.
Example:
{
"user.name": "Name",
"user.age": "Age",
"messages.welcome": "Welcome"
}
You can choose either of these structures based on your project requirements. The method languagesModel.saveToFolder(folderPath, structureStyle) allows you to specify the structure style as 'nest' or 'flat' when saving the i18n data to a local folder. Similarly, when loading data from a folder using GoogleSheetLanguagesModel.loadFromFolder(folderPath, languages, structureStyle), you can specify the structure style to match the organization of your i18n data.
Example:
// Saving data in nest structure
languagesModel.saveToFolder(folderPath, "nest");
// Or, saving data in flat structure
languagesModel.saveToFolder(folderPath, "flat");
This flexibility allows you to work with the i18n data in a way that's most convenient and logical for your project's organization.
If you encounter any issues or have features requests, feel free to open an issue or submit a pull request. Your contributions are welcome!
FAQs
# Google Sheet Languages Model - i18n google sheet layer
We found that google-sheet-languages-model-2 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket’s new Pull Request Stories give security teams clear visibility into dependency risks and outcomes across scanned pull requests.

Research
/Security News
npm author Qix’s account was compromised, with malicious versions of popular packages like chalk-template, color-convert, and strip-ansi published.

Research
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.