matheuss / google-translate-api

A free and unlimited API for Google Translate :dollar::no_entry_sign:
https://npmjs.com/package/google-translate-api
MIT License
2.91k stars 608 forks source link

Text direction #91

Open matheus-rosin opened 5 years ago

matheus-rosin commented 5 years ago

I think a good new resource would be a new export declaration in languages.js called rtl, which stands for "right to left".

There is a CSS property called direction for setting how to show text in a node, whether from left to right (most languages) or from right to left (just a few ones).

Exporting such a variable would be agreeable for those who want to show a properly styled input, for example (that is what I need right now, reason why I've implemented by myself).

For now, it would be like this:

var rtl = [
  'ar', // arabic
  'iw', // hebrew
  'ps', // pashto
  'fa', // persian
  'sd', // sindhi
  'ur', // urdu
  'yi'  // yiddish
];

And then, a good practice would be export a function for saying if a language is rtl based on its "key":

function isRtl(key) {
  return rtl.includes(key);
}

// isRtl('en') => false