tree-species-i18n
TypeScript icon, indicating that this package has built-in type declarations

1.0.9 • Public • Published

Tree Species

This repository includes lists of tree species with corresponding translation. It is intended to support forest-specific software to get ready for internationalization.

Install

Using npm:

npm i tree-species-i18n

Using CDN

https://cdn.jsdelivr.net/npm/tree-species-i18n@1.0.6/dist/index.esm.js

Usage

import * as treeSpeciesI18n from 'tree-species-i18n';

// Search for id by species name and language code (en, es, de or leave empty to get default user language in browser).
var treeNameToSearch = 'silver fir';
var treeSpeciesId = treeSpeciesI18n.encode(treeNameToSearch, 'en');

// Search for species name by id and language code 
var treeName = treeSpeciesI18n.decode(treeSpeciesId, 'es');

// Get tree list by language code
// Supported languages: en, es, de
var speciesArrayDe = treeSpeciesI18n.getList('de');
console.info('List of species (de): ', speciesArrayDe.length);

// Returns a list of tree species, in the selected language, that are native to the specified country code.
// Supported country codes: de, at, ch, se, fr, no, jp, uk, us
var speciesArrayDeJP = treeSpeciesI18n.getList('de', 'JP');
console.info('List of species (de) in JP: ', speciesArrayDeJP.length);

// Get color by species id
var speciesColor = treeSpeciesI18n.getColorFromId(treeSpeciesId);
console.info('%c Color by key: ' +speciesColor, 'color: #' + speciesColor);

// Get random tree species by language code
var randomSpeciesId = treeSpeciesI18n.getRandomSpeciesId('en');
console.info('Random species id (en): ' +randomSpeciesId);

Examples

Node, Browser (CDN) and bundled Examples.

Structur

Scientific Name

The list of scientific names includes about 58000 tree species. The scientific name should be unique. Nevertheless, it is recommended to use the unique ID offered for clear and short identification beyond your own software.

Translations

The current locales files include one ore more translations of the scientific name.

The length of the list of translations varies. Only species that provide a translation are listed.

More languages

Create an issue for feature or language requests.

Credits

The scientific names are taken from GlobalTreeSearch.

Translations are automatically generated using the Wikipedia API.

Package Sidebar

Install

npm i tree-species-i18n

Weekly Downloads

0

Version

1.0.9

License

MIT

Unpacked Size

3.64 MB

Total Files

9

Last publish

Collaborators

  • gruenecho