Socket
Socket
Sign inDemoInstall

@hammerhq/localization

Package Overview
Dependencies
1
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @hammerhq/localization

✨ YAML based localization system for everyone!


Version published
Maintainers
1
Created

Readme

Source

Logo

Hammer Framework Logger Package

✨ YAML based localization system for everyone!
Get support »

Report Bug · Documentation

@hammerhq/localization

  • This is a YAML based localisation system that will make your job quite easy
  • Just create your language folder and seperate everything in files
  • Set your constants in constants.yaml and apply to everything

📦 Installation

$ npm install @hammerhq/logger

🚀 Usage

import { I18n } from "@hammerhq/localization";

/*
    options:
        directory?: string;
        defaultLocale: string;
*/
const parser = new I18n({
	defaultLocale: "en",
});

parser.getLocales(); // => [ "en", "tr" ];
parser.getConstant(); // => all constants;
parser.getConstant("owner"); // => "owner" constant;
parser.toJSON(); // => all language data in an object
parser.toJSON({ arg: "this is an argument" }); // => all language data in an object with argument replaced

parser.get("en", "info", "test"); // "test" string in "info" section in "en" folder
parser.get("tr", "messages", "message", { arg: "this is an argument" }); // "message" string in "messages" section in "tr" folder with "arg" argument

📝 File Structure

locales/constants.yaml example

owner: barbarbar338
site: "https://hammer.338.rocks"
anotherConstant: this is a constant

locales/{locale}/{section}.yaml example

withConstant: this string uses %{owner} constant
withArgs: this string uses %{argument} argument and %{anotherArgument} argument
withConstantsAndArguments: this string uses %{simpleArgument} argument and %{site} constant

📁 Folder Structure

📂 locales/
├─── 📝 constants.yaml
├─── 📂 en
│    ├─── 📝 info.yaml
│    ├─── 📝 messages.yaml
│    └─── 📝 test.yaml
└─── 📂 tr
     ├─── 📝 info.yaml
     ├─── 📝 messages.yaml
     └─── 📝 test.yaml

🧦 Looking For Contributors

We are looking for contributors to actively work on Hammer and to contribute to the repos. There is still lots of work to do. If you are interested in contributing, please join our Discord server. (There will be a surprise for early contributors!)

🔑 License

Copyright © 2022 Barış DEMİRCİ.

Distributed under the GPL-3.0 License. See LICENSE for more information.

🧦 Contributing

This repo is open for #hacktoberfest. Feel free to use GitHub's features.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/my-feature)
  3. Run prettier (npm run format)
  4. Commit your Changes (git commit -m 'my awesome feature my-feature')
  5. Push to the Branch (git push origin feature/my-feature)
  6. Open a Pull Request

⭐️ Show your support

Give a ⭐️ if this project helped you!

☎️ Contact

Keywords

FAQs

Last updated on 26 Nov 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc