wooorm / franc

Natural language detection
https://wooorm.com/franc/
MIT License
4.07k stars 175 forks source link

ISO-639-1 codes #61

Closed thiagodp closed 5 years ago

thiagodp commented 6 years ago

Hello, first of all thanks for this great project! Since Franc appears to use ISO-639-3 codes (right?), I was wondering if it can also return ISO-639-1 codes. If it can't, I think it may worth it to create a section like See Also in README.md with some libraries that may help with that, such as nodejs-langs. For instance:

var franc = require( 'franc' );
var langs = require('langs');
var iso_639_3 = franc('O Brasil caiu 26 posições' );
langs.where( "3", iso_639_3 );
// { '1': 'pt', '2': 'por', '3': 'por', name: 'Portuguese', local: 'Português', '2T': 'por','2B': 'por' }
brettimus commented 5 years ago

Good tip 😁 . I opened a PR as thanks, since this was super helpful for me!

thiagodp commented 5 years ago

@brettimus Thank you! ;)

amitbend commented 5 years ago

I created a new slim package to convert between iso-639-3 to iso-639-1, For languages without iso-639-1 that have a "macro language". PR are welcome! iso-639-3-to-1 package