name-db icon indicating copy to clipboard operation
name-db copied to clipboard

Name translation route

Open evaporei opened this issue 8 years ago • 2 comments

Added new route to the project: GET /:name/:language This solves the second item of this issue: #198

This pull request was made before and some changes were requested (#217):

  • I feel like this route should only return a string, I don't see the point of returning the name and the language.

  • It should also find translations of aliases, for example: http://localhost:3000/david finds dave, which is an alias of david, but http://localhost:3000/david/deu doesn't find the German translation of dave, and I feel like it should.

  • As I commented in #198, I'd want the API to be able to recognize both language codes and language names, so I except http://localhost:3000/daniel/Arabic to work as well as http://localhost:3000/daniel/ara

The first one was solved, however the other two weren't.

About the second change requested, I got a bit confused when I read it again. Because aliases don't have translations only the real name, I want to know if a request to /dave/deu should return the translation to david

About the third change requested, I want to know were should I get the full name of a language that I only have the short name of it. Looking on the database I found these tables: 'Meanings', 'Translations' and 'Aliases'. But I did not find in any of those the information to look for a relation of languages and their shortnames.

evaporei avatar Nov 05 '17 11:11 evaporei

Check out the iso-639-3 package on npm. It's already included as a dependency in package.json, so you should be able to use it to look up the short code using the iso6393 and name properties.

Line 49 shows how you can do a lookup with it

chrisf avatar Nov 06 '17 16:11 chrisf

Thanks @chrisf, that's correct. Hope that answers your question.

As to the alias idea - We'll sort this in another PR, for now, please just do the full-language part, and I'll merge it.

bluzi avatar Nov 08 '17 23:11 bluzi