## $Id$ ## Library of WML functions of general interest. ## This file is part of CDS Invenio. ## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN. ## ## CDS Invenio is free software; you can redistribute it and/or ## modify it under the terms of the GNU General Public License as ## published by the Free Software Foundation; either version 2 of the ## License, or (at your option) any later version. ## ## CDS Invenio is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## You should have received a copy of the GNU General Public License ## along with CDS Invenio; if not, write to the Free Software Foundation, Inc., ## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. ## language handling: #use wml::std::lang ## library of WML functions of general interest: <: sub get_language_name { ## Return long name for a language. ## Input: en ## Output: English ($ln) = @_; %longnames = ('en' => 'English', 'fr' => 'Français', 'de' => 'Deutsch', 'es' => 'Español', 'ca' => 'Català', 'pt' => 'Português', 'it' => 'Italiano', 'ru' => 'Русский', 'sk' => 'Slovensky', 'cs' => 'Česky', 'no' => 'Norsk/Bokmål', 'sv' => 'Svenska', 'el' => 'Ελληνικά', 'uk' => 'Українська', 'ja' => '日本語', 'pl' => 'Polski'); return $longnames{$ln}; } sub generate_language_list_for_python { ## Return Python-ready language list out of user-configured WML language list. ## May return short or long version, depending on the first argument. ## Output example: ['en','fr'] ## Output example: [['en','English'],['fr','French']] ($type) = @_; $out = "["; foreach $ln (split /\s*,\s*/, '') { if ($type) { $out .= "['".$ln."','".get_language_name($ln)."'],"; } else { $out .= "'".$ln."',"; } } $out .= "]"; return $out; } sub generate_language_selection_box_for_html { ## Return HTML-ready language selection box links. ## Output example: ($filenamebase, $filenameextension) = split /\./, '$(WML_SRC_BASENAME)'; $out = "_(This site is also available in the following languages:)_
"; foreach $ln (split /\s*,\s*/, '') { $out .= ' '.get_language_name($ln).'   '; } return substr($out, 0, -2); } sub generate_pretty_version_string { ## Input: CVS DOLLAR Id DOLLAR string ## Output: nicely formatted version number suitable for `bibtaskex --version' ## Example: ``DOLLAR Id: webcoll.wml,v 1.41 2004/04/21 11:20:06 tibor Exp DOLLAR'' ## will generate output like ``CDS Invenio/0.3.2 webcoll/1.41'' ($out) = @_; ($junk, $filename, $revision, $date, $junk) = split / /, $out; $filename =~ s/\.wml,v//g; return "CDS Invenio/ " . $filename . "/" . $revision; } sub generate_pretty_revision_date_string { ## Input: CVS DOLLAR Id DOLLAR string ## Output: nicely formatted revision/date number suitable for Admin Guides ## Example: ``DOLLAR Id: webcoll.wml,v 1.41 2004/04/21 11:20:06 tibor Exp DOLLAR'' ## will generate output like ``CDS Invenio/0.3.2 webcoll/1.41'' ($out) = @_; ($junk, $filename, $revision, $date, $junk) = split / /, $out; return $revision . ", " . $date; } :>