Scoop -- the swiss army chainsaw of content management
Front Page · Everything · News · Code · Help! · Wishlist · Project · Scoop Sites · Dev Notes · Latest CVS changes · Development Activities
Polylinguality in Scoop: a label abstractor New Code
By sleeper22 , Section Code []
Posted on Sun Sep 16, 2001 at 12:00:00 PM PST
Working towards extracting the english language from scoop, i've started implementing an abstracted labelling system. The interface labelling if functional, but i want to see if anyone has concerns or suggestions -- in the approach as well as the details.

Keep in mind that this has the benefit of providing UI experts direct access to the labels (even in a monolingual site), so that word choice can be optimized for site usability. If the approach looks good, you're welcome to do any of the work of course...

NEW TABLES... (with sample data)

1.
create table langs (langid char(4) primary key, name char(204));
insert into langs values('en', 'English');
insert into langs values('pt', 'Portugues');

This will give us more human-readable names of languages, for pulldown menus and such. The language names should be in the language that they refer to. e.g. "Espanol" rather than "Spanish".

2.

create table labeltext (labelid varchar(32) not null, langid char(4) not null, text text);
insert into labeltext values ('section_news', 'en', 'news');
insert into labeltext values ('section_news', 'pt', 'noticias');
insert into labeltext values ('_meta_section_news', 'en', 'news section');
insert into labeltext values ('_meta_section_news', 'pt', 'regiao das noticias');

3.

another possibility is a labels table:

#create table labels (labelid char(32) primary key, desc_labelid char(32)); insert into labeltext values ('section_news', '_meta_section_news');

Which gives info about each label, such as a description (as a guide on a label editing page).

But so far i don't see a need for the labels table because the descriptions themselves (metalabels) would also need to be labels (to be language-independent); we can just enter these meta labels into the labeltext table too, named espcially -- i suggest "_meta_<labelid>" where <labelid> is the labelid of the label being described.

Although we can enter records for the metalabels in various languages into labeltext, we shan't want to go beyond that into meta metalabels, etc...

4.

Eventually we'll want to filter the stories by language, so i propose:

create table storylang (sid char(10) not null, langid char(4) not null);
insert into storylang values('2001/9/11/152848/349', 'en');

A story's language is selected on the submit story page. This is its own table so that it becomes possible for a given story to be marked as being in more than one language. We could use a multiple select box that defaults to the current session language.

For a translators' site i'm making, at least, i think it would be good to have bilingual stories. They would be visible to users of both languages, who would thus generate a bilingual thread. The author of the original, presumably a bilingual person, could read all comments together.

Every monolingual story would be hidden from users whose session languages do not match the story's language.

NEW VARS...

default_lang (default language for the site)
_langid (best left out of the admin interface, unless an override is desired)

NEW PREFS...

lang (not sure if this is useful, as long as a pulldown appears on every page)

LIBRARY CODE CHANGES...
1.

file: ApacheHandler.pm
location: i put this just above the line:
   $S->{UI}->{VARS}->{subtitle} = '';
but it's flexible. it's not much code, but should it tucked into a Language.pm file?
code:

        # Language choice
        if ($S->{UI}->{VARS}->{_langid}) {
            # Administrator override of language choice, possibly in error

        } elsif ($S->cgi->param('lang') =~ /^(\w+)$/) {
            # Language change via pulldown menu
            # Change language for this session
            $S->{UI}->{VARS}->{_langid} = $1;
            $S->session('lang', $1);

        } else {
            $S->{UI}->{VARS}->{_langid} = 
                $S->session('lang') ||
                    $S->prefs->{lang} ||  # this pref may not exist
                        $S->{UI}->{VARS}->{default_lang}; # VAR from admin
        }

2.

If we're supporting a userpref for lang choice, then we'll need to have $S->session('lang', $preferred_lang) called somewhere alongside those subs in Comments/Format.pm.

3.

We'll also want a page to edit the labels, similar to the VAR editing interface. i haven't done this yet.

4.

We'll also want stories to be language tagged, and the story displayer to hide stories whose language doesn't match the session language.

NEW BOXES...
1.

boxid: label
title: Labeller
template: empty_box
desc: Returns text in appropriate language, from labeltext table. content:

my $q_labelid = $S->db->quote($ARGS[0]);

foreach my $lang_var (qw(_langid default_lang)) {
  my($rv,$sth) = $S->db_select({
    WHAT => 'text',
    FROM => 'labeltext',
    WHERE => 'langid='. $S->db->quote($S->{UI}->{VARS}->{$lang_var}). 
                " and labelid=$q_labelid",
  });
 return $sth->fetchrow_array if ($rv>0);
}

return "$ARGS[1]";

---

Note that the BOX,label can take a second argument -- the default text to return, in case there is no entry for <labelid> in the labeltext table. This will allow us to start changing the code even before building (or creating) the labeltext table. We can replace any <english text> in the html with the call: "|BOX,label,<labelid>,<english text>|" where <labelid> is anything to uniquely identify the meaning of the label.

Should we shortcut the BOX,label sytax to just LABEL?

2.
boxid: select_lang
template: empty_box
content:
my $langid = $S->{UI}->{VARS}->{_langid};
my($content);

my($rv,$sth) = $S->db_select({
WHAT => 'langid,name',
FROM => 'langs',
});

return "" unless $rv;

$content .= "<FORM ACTION='/transler/' METHOD='POST'>";
$content .= "<SELECT NAME='lang' SIZE='1' onchange='form.submit();'>";

while (my $data = $sth->fetchrow_hashref) { 
 my $selected = ($data->{langid} eq $langid)? ' SELECTED' : '';
 $content .= "<OPTION VALUE='$data->{langid}'$selected>$data->{name}</OPTION>";
}

$content .= "</SELECT>";
$content .= "<input type='submit' value='switch' /></FORM>";
return $content;

--

This is just a pulldown language selecter to put in the header block or wherever, so that the user can switch the session language. best left out until the site has a reasonable amount of non-english labels and it's ready to be considered... multilingual!

< www.rantapalooza.com | Anarchy Online >

Menu
· create account
· faq
· search
· report bugs
· Scoop Administrators Guide
· Scoop Box Exchange

Login
Make a new account
Username:
Password:

Poll
Who has a need for a label-abstracted interface?
· A site of mine could use it. 40%
· I think it will be useful for scoop sites now or within a year. 20%
· Not worth the hassle at this point; maybe someday. 20%
· Everyone should learn English. 20%

Votes: 5
Results | Other Polls

Related Links
· Scoop
· More on New Code
· Also by sleeper22

Story Views
  58 Scoop users have viewed this story.

Display: Sort:
Polylinguality in Scoop: a label abstractor | 10 comments (10 topical, 0 hidden)
Well, maybe. (none / 0) (#1)
by panner on Sun Sep 16, 2001 at 06:55:12 PM PST

Well, first off, the story is kind of hard to read, formatting wise. I could probably clean it up for you, if you'd like (using <pre> for everything really does not help, and using <hx> instead of <b> would be nice).

Second, there's been consideration of I18N and such in scoop, but that's one of those things that you need to design the system around. We haven't even gotten all of the HTML out of the code yet, let alone moving text around so that it can be in other languages.

I don't think a langs table would be needed. More than likely, it would just be in a block, as a lot of stuff like that is now. Also, I don't think there is a need for a storylang table. Why would you mark a story as being in more than one language? Unless stories were expanded so that they had multiple copies of the same text stored with them (in different languages), then there is no point.

_langid probably wouldn't be a var. More like $S->{LANG} (in the style of $S->{USER} and friends, since this is set by the code and not the admin. I think the pref would be needed, since you'd want your langauge preference to carry between browsers.

As for hiding stories in different languages, this is understandable. However, it seems to me like there should at least be a box displaying titles of stories in other languages. Otherwise, the site could easily become several different sites, one per language. Or maybe users should be able to choose which languages they want to see stories in, along with what language they want to have "labels" done in.

Really, I'm all for multiple-language support in Scoop. However, I don't think it's really feasible to do it in a clean way right now. Things like sections, polls, stories, comments, and more need to be considered. For instance, what do you do about section titles? I really don't like using special names like "_meta_section_news" as the key for stuff like that.

One big problem is including the actual text. This would probably work using $S->text('id') in some places and %%TEXT,id%% in others. However, upgrading existing sites will be painful. Really painful. So the question is, how will multi-lingual support affect sites that are monolingual, or pre-existing sites? And how cleanly can this be implemented? From what I've considered in the past, it can't right now. So to me, it's a back-burner type thing. But what you've been working on could prove me wrong.

Also, a few notes on your code. First off, you probably want to call finish on all your $sth's (just in case). Second, I'm fairly sure that using single quotes instead of double quotes in XHTML isn't valid.



--
Keith Smiley



prior art, and some thoughts (none / 0) (#6)
by kellan on Mon Nov 19, 2001 at 03:39:36 PM PST

My first comment would be look at how its been done before, i18n can be very tricky.

Some thoughts:

  • When I was reading your post my first thought was, "Oh no, a flat language hierarchy!". It can be very useful to support locales beyond merely languages, the classic example being fr-CA (french canadian)
  • And remember there are other aspects to localization then translation. (Dates are particularily annoying)
  • Besides having a pull down to choose languages , it should also be aware of the HTTP header Accept-Language.
  • Consider allowing for mix-n-match translation. So much software takes an approach that if they can't find the right translation, they throw an error. I would prefer to see a websites best attempt then nothing at all.

I haven't looked at the scoop code base in a really long time, so I have no idea how feasible this is, but probably the best place to hook a gettext like system into the code would be at the template level. Have whatever code is responsible for loading html be language/locale aware.

Hopefully that wasn't all too obvious

kellan



Vorwerk (none / 0) (#7)
by maicer on Sun Sep 18, 2016 at 10:25:48 PM PST

It's quite possible that Matteo Renzi could soon appear wearing cheap football shirts emblazoned with the name of a family-run firm from the German city of Wuppertal. Italy's prime minister is an avowed fan of ACF Fiorentina, the top-league soccer club of his native city Florence, and the team recently signed a sponsorship deal with moncler outlet. The company is the Italian division of Wuppertal-based Vorwerk, which makes a well-known vacuum cleaner called the Kobold in Germany and the Folletto in Italy. The Fiorentina team now wears violet-colored soccer replica jerseys that prominently feature the name "Folletto." In games in the European League, "Vorwerk" is to be emblazoned on the team's white jerseys.



nice post (none / 0) (#8)
by scalett on Thu Oct 20, 2016 at 04:40:14 AM PST

From his teenage years until today, Ralph Lauren has always expressed a burning, desire to create fashion Cheap Ralph Lauren Outlet for men, women and children that is far from the ordinary. Blessed with a natural, in-born gift for fashion-designing, the uncanny ability to set new trends in fashion design, and a sharp eye for detail, style and elegance, Ralph Lauren painstakingly, built the fashion Ralph Lauren Outlet UK it is today.The Ralph Lauren Shirts embody the very talents and spirit described above and reflects everything that this fashion mogul is all about. Purchasing Ralph Lauren Shirts is easy if you have the bucks, and know a little about what types of shirts are marketed under this top-drawer, luxury designer label. For example, a wide variety of casual and semi-formal, Ralph Lauren Shirts are available under his signature, "Purple" label collection. For more formal men's Ralph Lauren Outlet wear, such as the exquisite, Ralph Lauren dress shirts, you may check his "Black" label collection. Of course, if you're looking for the perennial, favorite - Ralph Lauren Polo at http://www.ukralphlauren.co.uk Shirts - there's the separate 'Polo Ralph Lauren' collection, too.



payday loans (none / 0) (#9)
by Pervez on Sun Apr 15, 2018 at 03:45:51 PM PST

Superior content! We're unquestionably pleasantly surprised to work out below we will. Recently I appeared into your blog page on the subject of chiropractic treat combined with was required to tell us everyone your own quite preferred looking around your blog post website content. These days follow here payday loans Remarkable used, unquestionably training. Maintain acknowledge that there are succeed. Thanks once and for good feature.



best bathroom remodeling near me (none / 0) (#10)
by Pervez on Sun Apr 07, 2019 at 08:02:59 AM PST

Terrific practical webpage! My organization is basically definitely gratified soon after perusing this blog post. That I very seriously enjoy an individual's patience you would probably pay out to specific this valuable approximately! Right now, push best bathroom remodeling near me I really undertake like to look through even more shifts by someone.



Polylinguality in Scoop: a label abstractor | 10 comments (10 topical, 0 hidden)
Display: Sort:

Hosted by ScoopHost.com Powered by Scoop
All trademarks and copyrights on this page are owned by their respective companies. Comments are owned by the Poster. The Rest © 1999 The Management

create account | faq | search