npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@dchighs/dc-localization

v0.0.6

Published

A library to handle localization for Dragon City.

Readme

@dchighs/dc-localization

@dchighs/dc-localization is a package for accessing, manipulating, and comparing translation data from the game Dragon City (this is not an official library by SocialPoint; it is fan-made).

📦 Installation

Installation is straightforward; just use your preferred package manager. Here is an example using NPM:

npm i @dchighs/dc-localization @dchighs/dc-core

You need to install @dchighs/dc-core as well because I have set it as a peerDependency. This means the package requires @dchighs/dc-core as a dependency, but it will use the version the user has installed in the project.

🚀 Usage

Fetching localization for a specific language

To create a Localization instance, you need to provide data or use the static method .create(language: LocalizationLanguage) by providing a valid language code:

import { Localization } from "@dchighs/dc-localization"
import { ConfigLanguage } from "@dchighs/dc-core"

;(async () => {
	const localization = await Localization.create(ConfigLanguage.English)
})();

Loading a saved localization from a file

Supposing you have saved a JSON file containing localization data and want to load it to perform operations using the class, you can do it as follows:

import { Localization, LocalizationData } from "@dchighs/dc-localization"
import { ConfigLanguage } from "@dchighs/dc-core"
import fs from "node:fs"

;(async () => {
	const filePath = "localization.json"
	const contentString = await fs.promises.readFile(filePath, { encoding: "utf-8" })
	const data = JSON.parse(contentString) as LocalizationData // If it is Record<string, string>
	// const data = Object.assign({}, ...JSON.parse(contentString)) // If it is Array<Record<string, string>>

	const localization = new Localization({
		language: ConfigLanguage.English,
		data: data
	})
})();

Getting values by Key, ID, and keys by Value

Getting value by key:

const value = localization.getValueFromKey("tid_unit_1000_name") // Nature Dragon

Getting key by value:

const key = localization.getKeyFromValue("Nature Dragon") // tid_unit_1000_name

Getting dragon name by ID:

const name = localization.getDragonName(1000) // Nature Dragon

Getting dragon description by ID:

const description = localization.getDragonDescription(1000) // The Nature Dragon loves humans, animals...

Getting attack name by ID:

const name = localization.getAttackName(1) // Punch

Getting skill name by ID:

const name = localization.getSkillName(1) // Rock Throw

Getting skill description by ID:

const description = localization.getSkillDescription(1) // Hits 1 to 5 times

Searching values and keys

Searching keys:

const resultKeys = localization.searchKeys({
	query: "INPUT_HERE",
	lowerCase: true, /* text normalization config */
	normalizeLetters: true, /* text normalization config */
	trimSpaces: true /* text normalization config */
})

Searching values:

const resultValues = localization.searchValues({
	query: "INPUT_HERE",
	lowerCase: true, /* text normalization config */
	normalizeLetters: true, /* text normalization config */
	trimSpaces: true /* text normalization config */
})

Transforming

To get an object, a Record<string, string>:

const data = localization.toObject() // or localization.data

To get an array, an Array<Record<string, string>>:

const data = localization.toArray()

Comparing localizations

If you want to find the difference between two localization files, just use the static Localization.compare(a: Localization, b: Localization) or the instance method Localization.compare(other: Localization):

;(async () => {
	const filePath = "localization.json"
	const contentString = await fs.promises.readFile(filePath, { encoding: "utf-8" })
	const data = JSON.parse(contentString) as LocalizationData
	
	const oldLocalization = new Localization({
		language: ConfigLanguage.English,
		data: data
	})
	
	const newLocalization = await Localization.create("en")
	
	const comparisonResult = newLocalization.compare(oldLocalization) // { newFields: [...], editedFields: [...], deletedFields: [...] }
})();

Translating configuration

If you are dealing with game configuration data, you can translate it more easily using the .translate(object: any) method from Localization:

const dragon = {...}

const translatedDragon = localization.translate(dragon)

🤝 Contributing

  • Want to contribute? Follow these steps:
  • Fork the repository.
  • Create a new branch (git checkout -b feature-new).
  • Commit your changes (git commit -m 'Add new feature').
  • Push to the branch (git push origin feature-new).
  • Open a Pull Request.

📝 License

This project is licensed under the MIT License.