The holy grail is something that will translate an entire EPG dat and then save it so that the translated EPG then lasts for about a week.
Now if you could find something to do that then that would be awesome.
The holy grail is something that will translate an entire EPG dat and then save it so that the translated EPG then lasts for about a week.
Now if you could find something to do that then that would be awesome.
The holy grail is something that will translate an entire EPG dat and then save it so that the translated EPG then lasts for about a week.
Now if you could find something to do that then that would be awesome.
details ??
:)
There are no details to give.
Basically EPG is downloaded on an E2 box and stored in a .dat file. This file contains loads of different languages, and most users want the entire .dat file translated into English so when E2 loads the file all EPG is in English.
I was just passing comment that this would be the holy grail. Because still after all of these years no one has managed to do this.
well..
Maybe we can discuss it...
Google Translate's APIs are slow, translating word by word takes a while...
But there are so many of us developers, the idea could be feasible.
There are no details to give.
Basically EPG is downloaded on an E2 box and stored in a .dat file. This file contains loads of different languages, and most users want the entire .dat file translated into English so when E2 loads the file all EPG is in English.
I was just passing comment that this would be the holy grail. Because still after all of these years no one has managed to do this.
Epgtranslator do that
Why epgtranslator and not translate the epg.dat
Cause a lot of channels has eit epg so is not stored in dB but in enigma2 epgcache
So the best way is using epgtranslator
Cause a lot of channels has eit epg so is not stored in dB but in enigma2 epgcache
Iinitially yes EIT EPG is saved in the cache, but if the user then selects save EPG its then stored in the .dat
But the user can turn EIT off if he so desires and just download from rytec meaning all various languages are in the .dat right away.
Its this .dat file that then needs to be translated and the translated .dat saved afterwards to /media/hdd or usb.
I know this sounds much easier than it is and its this difficulty why so far it hasnt been done, but if someone can do it then as I said its the holy grail.
Since I have already worked on epgimporter, after years of not being updated and I see that many teams use it and everyone considers it a good base, I believe that:
I think it would be enough to modify epgdat_importer.py
Which is the entry point before creating the epg.dat file ;)
You don't need to translate epg.dat; it's a binary file.
An example of code to modify the epgdat_importer.py file to automatically translate titles, subtitles, and descriptions into English, automatically detecting the original language.
# At the beginning of the file, together with the other imports
from .translate_epg import translate_text # or from translate_epg import translate_text
class epgdatclass:
def __init__(self):
# ... (the rest of the original __init__) ...
# Set the target language (e.g. 'en' for English)
self.target_lang = 'en' # <--- Change here if you want another language
def importEvents(self, services, dataTupleList):
'''This method is called repeatedly for each bit of data'''
if services != self.services:
self.commitService()
self.services = services
# --- TRANSLATION BLOCK ---
translated_programs = []
for program in dataTupleList:
# program is a tuple: (start, duration, title, subtitle, description, ...)
title = program[2] if len(program) > 2 else ""
subtitle = program[3] if len(program) > 3 else ""
description = program[4] if len(program) > 4 else ""
# Translate only if the text is not empty
# and is not already in the target language (optional)
if title and isinstance(title, str):
translated_title = translate_text(
title,
target_lang=self.target_lang,
use_cache=True
)
else:
translated_title = title
if subtitle and isinstance(subtitle, str):
translated_subtitle = translate_text(
subtitle,
target_lang=self.target_lang,
use_cache=True
)
else:
translated_subtitle = subtitle
if description and isinstance(description, str):
translated_desc = translate_text(
description,
target_lang=self.target_lang,
use_cache=True
)
else:
translated_desc = description
# Rebuild the tuple with translated texts
# (preserving the remaining elements)
program_list = list(program)
program_list[2] = translated_title
program_list[3] = translated_subtitle
program_list[4] = translated_desc
translated_programs.append(tuple(program_list))
# --- END TRANSLATION ---
# Now use translated programs
for program in translated_programs:
if program[3]:
desc = program[3] + "\n" + program[4]
else:
desc = program[4]
self.epg.add_event(
program[0],
program[1],
program[2],
desc
)
# ... (any original code after the loop, if present) ...
Display More
You can add an option in the EPGImport configuration menu to enable or disable English translation, without having to manually edit the code each time.
# In EPGConfig.py, make sure the option is defined
# and globally accessible
# ... (other configurations) ...
if hasattr(config.plugins, "epgimport") and hasattr(
config.plugins.epgimport,
"translate_to_english"
):
translateToEnglish = config.plugins.epgimport.translate_to_english.value
else:
translateToEnglish = False # Default value if the option does not exist
Display More
The addition should be made at the point where the plugin's other configurations are read, such as `filterCustomChannel`.
Add the Menu Entry (plugin.py)
Edit the `plugin.py` file to add the new option to the configuration menu. You can do this inside the function that builds the configuration entries list (`getConfigList`). Insert something like:
# In plugin.py, inside the configuration entries list:
from .EPGConfig import translateToEnglish
# ...
config.plugins.epgimport.translate_to_english = ConfigYesNo(default=False)
config_list.append(
getConfigListEntry(
_("Translate EPG to English"),
config.plugins.epgimport.translate_to_english
)
)
The most important step: modify `epgdat_importer.py` to read this configuration and translate data only if the option is enabled. You will need to import both the translation module and the new configuration variable.
# In epgdat_importer.py
from .translate_epg import translate_text
from .EPGConfig import translateToEnglish # Import the configuration variable
class epgdatclass:
# ... (__init__ method) ...
def importEvents(self, services, dataTupleList):
# ... (existing code) ...
if services != self.services:
self.commitService()
self.services = services
# Determine whether translation is enabled ONLY ONCE before the loop
# This avoids reading the configuration file for every event
do_translate = translateToEnglish # translateToEnglish is True/False
# --- TRANSLATION BLOCK (OPTIONAL) ---
translated_programs = []
for program in dataTupleList:
# If translation is NOT enabled, use original data unchanged
if not do_translate:
translated_programs.append(program)
continue
# ... (then the translation logic you already wrote) ...
# Extract, translate, and rebuild the tuple
# ...
translated_programs.append(translated_program)
# --- END BLOCK ---
# Now use the programs (translated or original)
for program in translated_programs:
# ... (the rest of the code for adding events) ...
Display More
This is just an example, not tested or anything else. Just to give you a sense of direction.
Attached my python code translate_epg