Otras idiomas
Me gustaría hacer esto por el Frances, Koreano y otras idiomas. Es dificil?
@gcqmkm02 Disculpame, nunca vi este issue
@kamara how difficult would it be to support another languages?
🔍 Analysis for Issue #4
Adding support for additional languages like French and Korean to the wikiquotes-python-api is certainly possible, but requires some specific work. Here's what would be needed:
Implementation Requirements
-
Create new language modules: You would need to create new Python files in the
wikiquotes/languages/directory (similar toenglish.pyandspanish.py) for each language you want to support. For example:french.pykorean.py
-
Each language module needs to define:
base_urlpointing to the appropriate Wikiquote API (e.g., "https://fr.wikiquote.org/w/api.php" for French)quote_of_the_day_urlfor the language's quote of the day page- A
quote_of_the_day_parser()function that can extract quotes from the HTML structure of that language's Wikiquote page non_quote_sectionslist with section names to exclude (in that language)
-
Update the language manager: Modify
language_manager.pyto recognize and support the new languages in thefrom_string()function.
Challenges
The main challenge is that each language's Wikiquote page may have a different HTML structure. You'll need to:
- Analyze the HTML structure of each language's Wikiquote pages
- Create custom parsing logic for each language (especially for the quote of the day feature)
- Identify the non-quote sections in each language
Example for French
For French, you might create a file like:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
base_url = "https://fr.wikiquote.org/w/api.php"
quote_of_the_day_url = "https://fr.wikiquote.org/wiki/Wikiquote:Citation_du_jour"
def quote_of_the_day_parser(html):
# This would need to be customized based on the actual HTML structure
# of the French Wikiquote page
# ...
return (quote, author)
non_quote_sections = ["à propos", "références", "liens externes"]
Then update the language manager to recognize French:
elif lowered == u"fr" or lowered == u"french" or lowered == u"francais":
return french
Difficulty Level
The difficulty is moderate:
- The framework for adding languages is already in place
- The main work is understanding the HTML structure of each language's Wikiquote pages
- Testing would be needed to ensure proper handling of different character sets (especially for Korean)
Would you like me to provide more specific guidance for implementing any particular language?
📁 Files Examined
View Files
wikiquotes/languages/__init__.pywikiquotes/languages/english.pywikiquotes/languages/spanish.pywikiquotes/managers/language_manager.pywikiquotes/wikiquotes_api.py
📋 Available Kamara Commands
You can use the following commands in your comments:
- @kamara implement this - Request Kamara to implement this feature or fix
- @kamara analyze this - Request Kamara to analyze this issue (default when mentioning Kamara)