New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve and translate Fdroid metadata #8225
Comments
None of us know — or rather, you'd have to do some things on https://hosted.weblate.org/create/component/ with the manual in another window. Do we want that kind of translation activity on the main repo? |
I guess it is ok to pull translations manually once a year :) |
Other way of doing translations (maybe too odd) is to use the regular translations, append the whole fdroid metadata as a single string and write a tool that generates the plain text for each language. So the workflow would be - again, once a year or so -:
In that example the |
I don't know about odd but it does sound like reinventing the wheel. It seems like a topic they'd cover over on F-Droid somewhere? |
Actually the whole point about having metadata ourselves was/is to have some degree of control over screenshots and app description. First was #5726 but fdroid server wasn't able to fetch metadata from a submodule, so it was changed to the main repo in 9b6483e
A bit but we need to translate only two strings and the whole script is trivial. I just wrote a test script for the fun of it: #!/usr/bin/env luajit
require "defaults"
package.path = "frontend/?.lua;" .. package.path
local function isLocaleDir(str)
for _, v in ipairs({"templates", "README.md", "LICENSE"}) do
if str == v then return false end
end
return true
end
local function testAString(str, path)
local locales = {}
local output = io.popen('ls l10n')
if not output then return end
for dir in output:lines() do
if isLocaleDir(dir) then
locales[#locales + 1] = dir
end
end
output:close()
print('translation for "' .. str .. '"')
for __, lang in ipairs(locales) do
local _ = require("gettext")
_.changeLang(lang)
local translation = _(str)
if str == translation then
print(lang, "not translated")
else
print(lang, '"' .. translation .. '"')
end
end
end
testAString("Open with…") It works but seems to got hit by a bug or something is missing for a specific locale
|
Alright, that looks pretty decent. So we just have a few "ghost" strings as part of the regular flow. Works for me. 👍 Latvian is a language that seems to have been translated a decent amount recently but isn't exposed in the GUI yet. It's likely the plural form can't quite be parsed by the limited parser I wrote. Something along the lines of your script there would actually be a good thing to add to the CI tests. :-) |
@Frenzie: great. Now it works fine, thanks! I updated the script to do what's intended to do. A question: do translated strings get picked from If the answer to the first question is "yes" then it should work as is #!/usr/bin/env luajit
-- utility to generate fastlane metadata for each translation
-- usage: ./tools/update_metadata.lua
-- app short description
local template_short = "Ebook reader with support for many formats like PDF, DjVu, EPUB, FB2, CBZ."
-- app full description
local template_full = [[
* portable: runs on embedded devices (Cervantes, Kindle, Kobo, PocketBook), Android and Linux computers. Developers can run a KOReader emulator in Linux and MacOS.
* multi-format documents: supports fixed page formats (PDF, DjVu, CBT, CBZ) and reflowable e-book formats (EPUB, FB2, Mobi, DOC, CHM, TXT). Scanned PDF/DjVu documents can also be reflowed with the built->
* full-featured reading: multi-lingual user interface with a highly customizable reader view and many typesetting options. You can set arbitrary page margins, override line spacing and choose external fo>
* integrated with calibre (search metadata, receive ebooks wirelessly, browse library via OPDS), Wallabag, Wikipedia, Google Translate and other content providers.
* optimized for e-ink devices: custom UI without animation, with paginated menus, adjustable text contrast, and easy zoom to fit content or page in paged media.
* extensible via plugins
* and much more: look up words with StarDict dictionaries / Wikipedia, add your own online OPDS catalogs and RSS feeds, online over-the-air software updates, an FTP client, an SSH server, …
]]
require "defaults"
package.path = "frontend/?.lua;" .. package.path
local _ = require("gettext")
local metadata = {
source_short = template_short,
source_full = template_full,
translated_short = _(template_short),
translated_full = _(template_full),
}
local metadata_files = {
["short_description.txt"] = metadata.source_short,
["full_description.txt"] = metadata.source_full,
}
local function isFile(str)
local f = io.open(str, "r")
if f then
f:close()
return true
end
return false
end
local function writeFile(str, path)
local f = io.open(path, "w")
if f then
f:write(str)
f:write("\n")
f:close()
end
end
local function isLocaleDir(str)
for _, v in ipairs({"templates", "README.md", "LICENSE"}) do
if str == v then return false end
end
return true
end
local function getLocales()
local locales = {}
local output = io.popen('ls l10n')
if not output then return {} end
for dir in output:lines() do
if isLocaleDir(dir) then
locales[#locales + 1] = dir
end
end
output:close()
return locales
end
local function updateMetadata(str, path)
local locales = getLocales()
local count = { new = 0, updated = 0, not_translated = 0 }
for __, lang in ipairs(locales) do
_.changeLang(lang)
local translation = _(str)
if str ~= translation then
local metadata_dir = "metadata/" .. lang
local metadata_file = metadata_dir .. "/" .. path
os.execute('mkdir -p ' .. metadata_dir)
if isFile(metadata_file) then
count.updated = count.updated + 1
else
count.new = count.new + 1
end
writeFile(translation, metadata_file)
else
count.not_translated = count.not_translated + 1
end
end
print(path, "new", count.new, "updated", count.updated, "not translated", count.not_translated)
end
-- update english metadata first
local en_metadata = "metadata/en-US/"
for file, str in pairs(metadata_files) do
writeFile(str, en_metadata .. file)
end
-- update translated metadata
for file, str in pairs(metadata_files) do
updateMetadata(str, file)
end |
Yes, the required magic is that they're surrounded by |
Btw, don't bother the translators with stuff like leading newlines. Concatenate those outside of the text to be translated. I.e., "\n\n" .. _([[to be translated]]) |
I used the magic trick in local metadata = {
source_short = template_short,
source_full = template_full,
translated_short = _(template_short),
translated_full = _(template_full),
} 😄 |
Which won't work to pick up the strings. |
Done in ee35257 |
Each new package at https://f-droid.org/en/packages/org.koreader.launcher.fdroid/ pulls metadata from https://github.com/koreader/koreader/tree/master/metadata/
- [ ] adapt to fdroid users (mention specific android/ko oddities)The text was updated successfully, but these errors were encountered: