meikidd / iso-639-1 Goto Github PK
View Code? Open in Web Editor NEWISO-639-1 codes
Home Page: https://npmjs.org/package/iso-639-1
License: Other
ISO-639-1 codes
Home Page: https://npmjs.org/package/iso-639-1
License: Other
For example, catalan
is lowercase, and I need all uppercase native names
Hi there, we’re running into an issue where we need a third component in the code: transloadit/uppy#1614 (comment)
How do you recommend we handle this? Do/will you have support for this?
Do you have a changelog? It would be nice to have some context for upgrades to make sure they are well tested.
If this node module is used in a build that applies the webpack UglifyJS plugin, it will throw an error. See WikiEducationFoundation/WikiEduDashboard#1855 (comment)
Maybe that's not a bug with this package per-se, but might require workarounds for some projects so I'm opening an issue in case it's helpful. I wasn't able to find a way around the problem, so I ended up copying over the data.js file into my project instead.
In index.js, the require('babel-polyfill')
pulls in all of babel-polyfill. That leads to a huge amount of polyfills being brought in for a small library. In my webpack output, iso-639-1 is less than 10kb, and there was at least 100kb worth of polyfills being brought in because of babel-polyfill.
I'm getting this error when passing a string to ISO6391.getCode()
I'm on "iso-639-1": "^2.1.15",
Getting this after migrating the project to typescript
When I import this module using the next code
import ISO6391 from 'iso-639-1';
console.log(ISO6391.getAllCodes());
I've got the error "Cannot read properties of undefined (reading 'getAllCodes')" however, if I import it using require all works fine, but, it is not normal to have code like this, it is not harmonics.
import { Injectable } from '@nestjs/common';
import { CreateLanguageDto } from './dto/create-language.dto';
import { UpdateLanguageDto } from './dto/update-language.dto';
const ISO6391 = require('iso-639-1'); //import is not working
Could you fix this please ?
I get this error with the new version:
main.js:1:21 - error TS7016: Could not find a declaration file for module 'iso-639-1'. '/private/tmp/iso-bug/node_modules/iso-639-1/src/wrapper.mjs' implicitly has an 'any' type.
There are types at '/private/tmp/iso-bug/node_modules/iso-639-1/index.d.ts', but this result could not be resolved when respecting package.json "exports". The 'iso-639-1' library may need to update its package.json or typings.
1 import ISO6391 from "iso-639-1";
I believe you need to add types
/default
fields since the types are at a different location (index.d.ts
while the file is at src/wrapper.mjs
). More information here.
To reproduce the issue:
main.js
:
import ISO6391 from "iso-639-1";
jsconfig.json
:
{
"compilerOptions": {
"checkJs": true,
"target": "ES2022",
"module": "Node16",
"maxNodeModuleJsDepth": 0,
"strict": true
}
}
package.json
:
{
"type": "module",
"scripts": {
"typecheck": "tsc -p jsconfig.json"
},
"dependencies": {
"iso-639-1": "^3.0.0"
},
"devDependencies": {
"typescript": "^5.1.6"
}
}
Command: npm run typecheck
Hey,
I noticed that the repository does not include a License file. This is a problem since in many jurisdictions the author retains all rights pertaining to his work (incl. usage elsewhere as a dependancy) unless explicitly stated otherwise. This makes adoption of or contribution to this package difficult.
Please consider adding a license. If you are not sure about what to pick, there are great resources for that out there!
Have a great day!
I Imported the library in the file but it always returns undefined
import {
registerDecorator,
ValidationOptions,
// ValidationArguments,
} from 'class-validator';
import ISO6391 from 'iso-639-1';
export function IsISO6391(
validationOptions?: ValidationOptions,
): PropertyDecorator {
return function (object: object, propertyName: string) {
registerDecorator({
name: 'IsISO6391',
target: object.constructor,
propertyName: propertyName,
options: validationOptions,
validator: {
validate(value: any) {
console.log(ISO6391);
return (
typeof value === 'string' &&
ISO6391.validate(String(value.toLocaleLowerCase()))
);
// you can return a Promise<boolean> here as well, if you want to make async validation
},
},
});
};
}
The function returns an empty string ''
when there is no match but the TypeScript signature doesn't include this type.
The core ISO6391.validate
method behaves incorrectly for prototype property names provided as code
parameters, e.g. "toString"
.
const ISO6391 = require('iso-639-1')
it('toString', function() {
assert.equal(ISO6391.validate('toString'), false); // fails: returns `true` unexpectedly
});
Dear iso-639-1 maintainers,
Thank you for your contribution to the open-source community.
This issue was automatically created to inform you a new version (2.1.14) of iso-639-1 was published without a matching tag in this repo.
As part of our efforts to fight software supply chain attacks, we would like to verify this release is known and intended, and not a result of an unauthorized activity.
If you find this behavior legitimate, kindly close and ignore this issue. Read more
Unlike getName()
that returns an empty string when called with a non-ISO language code, getCode()
throws an exception when called with a non-canonical, misspelled or inexistent language name:
iso.getCode('Tibetan'); // supposed to be Tibetan Standard...
~/project/node_modules/babel-runtime/helpers/slicedToArray.js:48
throw new TypeError("Invalid attempt to destructure non-iterable instance");
^
TypeError: Invalid attempt to destructure non-iterable instance
at ~/project/node_modules/babel-runtime/helpers/slicedToArray.js:48:13
at Function.ISO6391.getCode (/home/ubuntu/projects/learn_bpe/node_modules/iso-639-1/build/index.js:85:59)
at Object.<anonymous> (/home/ubuntu/projects/learn_bpe/cli.js:61:17)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.runMain (module.js:604:10)
at run (bootstrap_node.js:394:7)
(node v6.8.1 under ubuntu 14.04)
Error
const iso6391 = require('iso-639-1');
iso6391.validate('es');
Good
const iso6391 = require('iso-639-1').default;
iso6391.validate('es');
Hi!
error TS2345: Argument of type 'string' is not assignable to parameter of type 'LanguageCode'.
Even in documentation validate
is defined as receiving a string, the interface defined in index.d.ts expects a LanguageCode.
(Also happening for the rest of functions)
The typing information states that I should use a default export:
import iso6391 from 'iso-639-1'
Accessing (for example) iso6391.getAllCode
works according to typescript, but iso6391
is actually undefined
. It seems like it's actually a namespace import:
import * as iso6391 from 'iso-639-1'
Now TypeScript breaks, but the runtime code works.
My current workaround is:
import * as _iso6391 from 'iso-639-1'
const iso6391 = _iso6391 as any as typeof import('iso-639-1').default
Not sure if this has something to do with the allowSyntheticDefaultImports
option which I have set to true
, but I know it fiddles with namespace vs default imports... 🤔
Error: Cannot find module 'babel-runtime/core-js/object/keys'
at Function.Module._resolveFilename (module.js:472:15)
BTW if you're making some serious changes it's better and safer to update major version or at least minor, but not patch.
I have run into an issue where most things work fine.
But use case needs to support 639-2 language is there any extension to this library or can I raise PR including that language.
Hi,
On this web site
https://www.loc.gov/standards/iso639-2/php/code_list.php,
I found 2 more languages code
Regards
I upgraded my webpack version from 1 to 4 and now I get an error using "iso-639-1" lib in {getNativeName ,getCode} while importing .
Error I get "TypeError: (0 , _iso.getNativeName) is not a function”
Note:
import { getNativeName, getCode } from "iso-639-1" ;
was working fine with webpack 1 version and not able to import in webpack4.I was able to fix doing the below code snippet for webpack 4
const ISO6391 = require("iso-639-1");
const getNativeName = ISO6391.default.getNativeName;
const getCode = ISO6391.default.getCode;
but i am not confident about this fix .
Can you please help here for a proper fix ? Looks like this doesn't have proper ES modules support .
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.