obs = obslua -- Struktur zur Speicherung der Einstellungen für jede Textquelle source_settings = { {name = "", separator = ", ", show_time = true, show_uhr_text = true, show_weekday = false, show_calendar_week = false, show_date = false}, {name = "", separator = ", ", show_time = true, show_uhr_text = true, show_weekday = false, show_calendar_week = false, show_date = false}, {name = "", separator = ", ", show_time = true, show_uhr_text = true, show_weekday = false, show_calendar_week = false, show_date = false}, {name = "", separator = ", ", show_time = true, show_uhr_text = true, show_weekday = false, show_calendar_week = false, show_date = false}, {name = "", separator = ", ", show_time = true, show_uhr_text = true, show_weekday = false, show_calendar_week = false, show_date = false} } -- Setze die deutsche Locale os.setlocale("de_DE.UTF-8") -- Variable zur Verfolgung der letzten Aktualisierungszeit last_update_time = 0 update_interval = 20 -- Aktualisierungsintervall auf 20 Sekunden gesetzt -- Definition der Übersetzungen für unterstützte Sprachen local translations = { ["Deutsch"] = { day = {"So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"}, date = "%d.%m.%Y", time = "%H:%M", calendar_week = "KW ", uhr_text = "Uhr", description = "Ermöglicht das Aktualisieren von bis zu fünf Textquellen mit individuellen Einstellungen für Uhrzeit, 'Uhr'-Text, Datum, Wochentag und Kalenderwoche alle 20 Sekunden. Aktualisierung alle 20 Sekunden spart Ressourcen.", source_label = "Quelle ", separator_label = "Trennzeichen", show_time_label = "Uhrzeit anzeigen", show_uhr_text_label = "'Uhr' hinter Zeit anzeigen", show_date_label = "Datum anzeigen", show_weekday_label = "Wochentag anzeigen", show_calendar_week_label = "Kalenderwoche anzeigen" }, ["Français"] = { day = {"Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"}, date = "%d/%m/%Y", time = "%H:%M", calendar_week = "Sem ", uhr_text = "heures", description = "Permet de mettre à jour jusqu'à cinq sources de texte avec des paramètres individuels pour l'heure, le texte 'heures', la date, le jour de la semaine et la semaine du calendrier toutes les 20 secondes. La mise à jour toutes les 20 secondes économise des ressources.", source_label = "Source ", separator_label = "Séparateur", show_time_label = "Afficher l'heure", show_uhr_text_label = "Afficher 'heures' après l'heure", show_date_label = "Afficher la date", show_weekday_label = "Afficher le jour de la semaine", show_calendar_week_label = "Afficher la semaine du calendrier" }, ["Italiano"] = { day = {"Dom", "Lun", "Mar", "Mer", "Gio", "Ven", "Sab"}, date = "%d/%m/%Y", time = "%H:%M", calendar_week = "Set ", uhr_text = "ore", description = "Consente di aggiornare fino a cinque sorgenti di testo con impostazioni individuali per l'ora, il testo 'ore', la data, il giorno della settimana e la settimana del calendario ogni 20 secondi. L'aggiornamento ogni 20 secondi consente di risparmiare risorse.", source_label = "Fonte ", separator_label = "Separatore", show_time_label = "Mostra l'ora", show_uhr_text_label = "Mostra 'ore' dopo l'ora", show_date_label = "Mostra la data", show_weekday_label = "Mostra il giorno della settimana", show_calendar_week_label = "Mostra la settimana del calendario" }, ["Español"] = { day = {"Dom", "Lun", "Mar", "Mié", "Jue", "Vie", "Sáb"}, date = "%d/%m/%Y", time = "%H:%M", calendar_week = "Sem ", uhr_text = "horas", description = "Permite actualizar hasta cinco fuentes de texto con configuraciones individuales para la hora, el texto 'horas', la fecha, el día de la semana y la semana del calendario cada 20 segundos. Actualizar cada 20 segundos ahorra recursos.", source_label = "Fuente ", separator_label = "Separador", show_time_label = "Mostrar hora", show_uhr_text_label = "Mostrar 'horas' después de la hora", show_date_label = "Mostrar fecha", show_weekday_label = "Mostrar día de la semana", show_calendar_week_label = "Mostrar semana del calendario" }, ["Português"] = { day = {"Dom", "Seg", "Ter", "Qua", "Qui", "Sex", "Sáb"}, date = "%d/%m/%Y", time = "%H:%M", calendar_week = "Sem ", uhr_text = "horas", description = "Permite atualizar até cinco fontes de texto com configurações individuais para a hora, o texto 'horas', a data, o dia da semana e a semana do calendário a cada 20 segundos. Atualizar a cada 20 segundos economiza recursos.", source_label = "Fonte ", separator_label = "Separador", show_time_label = "Mostrar hora", show_uhr_text_label = "Mostrar 'horas' após a hora", show_date_label = "Mostrar data", show_weekday_label = "Mostrar dia da semana", show_calendar_week_label = "Mostrar semana do calendário" }, ["Українська"] = { day = {"Нд", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"}, date = "%d.%m.%Y", time = "%H:%M", calendar_week = "Тиж ", uhr_text = "годин", description = "Дозволяє оновлювати до п'яти текстових джерел з індивідуальними налаштуваннями для часу, тексту 'годин', дати, дня тижня та тижня календаря кожні 20 секунд. Оновлення кожні 20 секунд заощаджує ресурси.", source_label = "Джерело ", separator_label = "Розділювач", show_time_label = "Показати час", show_uhr_text_label = "Показати 'годин' після часу", show_date_label = "Показати дату", show_weekday_label = "Показати день тижня", show_calendar_week_label = "Показати тиждень календаря" }, ["Русский"] = { day = {"Вс", "Пн", "Вт", "Ср", "Чт", "Пт", "Сб"}, date = "%d.%m.%Y", time = "%H:%M", calendar_week = "Нед ", uhr_text = "часов", description = "Позволяет обновлять до пяти текстовых источников с индивидуальными настройками для времени, текста 'часов', даты, дня недели и недели календаря каждые 20 секунд. Обновление каждые 20 секунд экономит ресурсы.", source_label = "Источник ", separator_label = "Разделитель", show_time_label = "Показать время", show_uhr_text_label = "Показать 'часов' после времени", show_date_label = "Показать дату", show_weekday_label = "Показать день недели", show_calendar_week_label = "Показать неделю календаря" }, ["Türkçe"] = { day = {"Paz", "Pts", "Sal", "Çar", "Per", "Cum", "Cts"}, date = "%d.%m.%Y", time = "%H:%M", calendar_week = "Hf ", uhr_text = "saat", description = "Her 20 saniyede bir, saat, 'saat' metni, tarih, hafta günü ve takvim haftası için bireysel ayarlarla beş adede kadar metin kaynağını güncellemeyi sağlar. Her 20 saniyede bir güncelleme, kaynakları tasarruf sağlar.", source_label = "Kaynak ", separator_label = "Ayırıcı", show_time_label = "Saati göster", show_uhr_text_label = "Saatten sonra 'saat' göster", show_date_label = "Tarihi göster", show_weekday_label = "Hafta gününü göster", show_calendar_week_label = "Takvim haftasını göster" } } local selected_language = "Deutsch" local lang = translations[selected_language] function script_description() return lang.description end function script_properties() local props = obs.obs_properties_create() local language_list = obs.obs_properties_add_list(props, "language", "Sprache", obs.OBS_COMBO_TYPE_LIST, obs.OBS_COMBO_FORMAT_STRING) for language, _ in pairs(translations) do obs.obs_property_list_add_string(language_list, language, language) end for i = 1, 5 do local p = obs.obs_properties_add_list(props, "source" .. i, lang.source_label .. i, obs.OBS_COMBO_TYPE_EDITABLE, obs.OBS_COMBO_FORMAT_STRING) add_sources(p) obs.obs_properties_add_text(props, "separator" .. i, lang.separator_label, obs.OBS_TEXT_DEFAULT) obs.obs_properties_add_bool(props, "show_time" .. i, lang.show_time_label) obs.obs_properties_add_bool(props, "show_uhr_text" .. i, lang.show_uhr_text_label) obs.obs_properties_add_bool(props, "show_date" .. i, lang.show_date_label) obs.obs_properties_add_bool(props, "show_weekday" .. i, lang.show_weekday_label) obs.obs_properties_add_bool(props, "show_calendar_week" .. i, lang.show_calendar_week_label) end return props end function add_sources(property) local sources = obs.obs_enum_sources() if sources ~= nil then for _, source in ipairs(sources) do local source_id = obs.obs_source_get_unversioned_id(source) if source_id == "text_gdiplus" or source_id == "text_ft2_source" then local name = obs.obs_source_get_name(source) obs.obs_property_list_add_string(property, name, name) end end end obs.source_list_release(sources) end function script_update(settings) selected_language = obs.obs_data_get_string(settings, "language") or "Deutsch" lang = translations[selected_language] for i = 1, 5 do source_settings[i].name = obs.obs_data_get_string(settings, "source" .. i) source_settings[i].separator = obs.obs_data_get_string(settings, "separator" .. i) if source_settings[i].separator == "" then source_settings[i].separator = " " end source_settings[i].show_time = obs.obs_data_get_bool(settings, "show_time" .. i) source_settings[i].show_uhr_text = obs.obs_data_get_bool(settings, "show_uhr_text" .. i) source_settings[i].show_weekday = obs.obs_data_get_bool(settings, "show_weekday" .. i) source_settings[i].show_calendar_week = obs.obs_data_get_bool(settings, "show_calendar_week" .. i) source_settings[i].show_date = obs.obs_data_get_bool(settings, "show_date" .. i) source_settings[i].lang = lang end -- Sofortige Aktualisierung auslösen und Timer neu starten last_update_time = 0 script_tick(0) end function script_defaults(settings) obs.obs_data_set_default_string(settings, "language", "Deutsch") for i = 1, 5 do obs.obs_data_set_default_string(settings, "source" .. i, "") obs.obs_data_set_default_string(settings, "separator" .. i, ", ") obs.obs_data_set_default_bool(settings, "show_time" .. i, true) obs.obs_data_set_default_bool(settings, "show_uhr_text" .. i, true) obs.obs_data_set_default_bool(settings, "show_weekday" .. i, false) obs.obs_data_set_default_bool(settings, "show_calendar_week" .. i, false) obs.obs_data_set_default_bool(settings, "show_date" .. i, false) end end function script_save(settings) -- Save settings if needed end function script_load(settings) -- Load settings if needed end function script_tick(seconds) local current_time = os.time() if current_time - last_update_time >= update_interval then for i, setting in ipairs(source_settings) do update_source(setting.name, setting.separator, setting.show_time, setting.show_uhr_text, setting.show_weekday, setting.show_calendar_week, setting.show_date, setting.lang) end last_update_time = current_time end end function get_calendar_week() local current_date = os.date("*t") local jan1 = os.time{year = current_date.year, month = 1, day = 1} local day_of_year = os.date("%j") local jan1_weekday = os.date("%w", jan1) local week_num = math.ceil((day_of_year + jan1_weekday - 1) / 7) return week_num end function get_weekday_name(lang) local day_num = os.date("*t").wday return lang.day[day_num] end function update_source(source_name, separator, show_time, show_uhr_text, show_weekday, show_calendar_week, show_date, lang) local source = obs.obs_get_source_by_name(source_name) if source ~= nil then local components = {} if show_calendar_week then table.insert(components, lang.calendar_week .. get_calendar_week()) end if show_weekday then table.insert(components, get_weekday_name(lang)) end if show_date then table.insert(components, os.date(lang.date)) end if show_time then local time_text = os.date(lang.time) if show_uhr_text then time_text = time_text .. " " .. lang.uhr_text end table.insert(components, time_text) end local text = table.concat(components, separator) local settings = obs.obs_data_create() obs.obs_data_set_string(settings, "text", text) obs.obs_source_update(source, settings) obs.obs_data_release(settings) obs.obs_source_release(source) end end