Note that there are some explanatory texts on larger screens.

plurals
  1. POPygame, gettext and unicode strings
    primarykey
    data
    text
    <p>I am trying to translate a videogame <a href="https://github.com/mdtrooper/Obb" rel="nofollow">https://github.com/mdtrooper/Obb</a>, but the gettext method _("string") return a non unicode string.</p> <p>Well I have made a simple example to show the problem:</p> <p>The file is utf8 encoding:</p> <pre><code># -*- coding: utf-8 -*- import pygame, os import locale import gettext gettext.textdomain('caca') _ = gettext.gettext def main(): path_i18n = os.getcwd() + '/i18n/' gettext.bindtextdomain('caca', path_i18n) pygame.init() screen = pygame.display.set_mode((640, 480), 0, 32) screen.fill(pygame.Color(255, 255, 255, 255)) font = pygame.font.Font("Isuckatgolf.ttf", 30) text = font.render(_("caca"), True, pygame.Color(0, 0, 0, 255)) screen.blit(text, (0,0)) unstraslate_text = font.render(u"ñadu", True, pygame.Color(0, 0, 0, 255)) screen.blit(unstraslate_text, (100, 100)) pygame.display.update() exit = False while not exit: for e in pygame.event.get(): if e.type == pygame.QUIT: exit = True elif e.type == pygame.KEYDOWN: if e.key == pygame.K_ESCAPE: exit = True pygame.quit() if __name__ == '__main__': </code></pre> <p>And this is the po file for spanish:</p> <pre><code># SOME DESCRIPTIVE TITLE. # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # This file is distributed under the same license as the PACKAGE package. # FIRST AUTHOR &lt;EMAIL@ADDRESS&gt;, YEAR. # #, fuzzy msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" "POT-Creation-Date: 2013-03-30 14:06+0100\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME &lt;EMAIL@ADDRESS&gt;\n" "Language-Team: LANGUAGE &lt;LL@li.org&gt;\n" "Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: UTF-8\n" #: test.py:19 msgid "caca" msgstr "ñandu" </code></pre> <p>Of course the font haven't the Ñ or ñ character but I have modified for to add this characters, you can find in <a href="http://depositfiles.com/files/dwwmp912m" rel="nofollow">http://depositfiles.com/files/dwwmp912m</a></p> <p>With example the first string (the translated string) shows bad but the second shows good.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload