aboutsummaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-07-24 09:01:10 -0700
committerNils Dagsson Moskopp <nils@dieweltistgarnichtso.net>2011-07-24 09:01:10 -0700
commit71b7d925970f38a993ff9f7c3f3939a0c0b8112b (patch)
treeb8bf1e95011a901b0e20e1cb283b7d0ed98a9030 /util
parentf4a08f7fb3c9a249ad1256e2cf1a2e2ca3f2a709 (diff)
parente034f8a2a372279edfc5a6c69dc14fb31c9a7685 (diff)
downloadminetest-71b7d925970f38a993ff9f7c3f3939a0c0b8112b.tar.gz
minetest-71b7d925970f38a993ff9f7c3f3939a0c0b8112b.tar.bz2
minetest-71b7d925970f38a993ff9f7c3f3939a0c0b8112b.zip
Merge pull request #35 from Oblomov/master
some more gettext fixes
Diffstat (limited to 'util')
-rwxr-xr-xutil/updatepo.sh65
1 files changed, 65 insertions, 0 deletions
diff --git a/util/updatepo.sh b/util/updatepo.sh
new file mode 100755
index 000000000..bcfa4c4de
--- /dev/null
+++ b/util/updatepo.sh
@@ -0,0 +1,65 @@
+#!/bin/sh
+
+# Update/create minetest po files
+
+# an auxiliary function to abort processing with an optional error
+# message
+abort() {
+ test -n "$1" && echo >&2 "$1"
+ exit 1
+}
+
+# The po/ directory is assumed to be parallel to the directory where
+# this script is. Relative paths are fine for us so we can just
+# use the following trick (works both for manual invocations and for
+# script found from PATH)
+scriptisin="$(dirname "$(which "$0")")"
+
+# The script is executed from the parent of po/, which is also the
+# parent of the script directory and of the src/ directory.
+# We go through $scriptisin so that it can be executed from whatever
+# directory and still work correctly
+cd "$scriptisin/.."
+
+test -e po || abort "po/ directory not found"
+test -d po || abort "po/ is not a directory!"
+
+# Get a list of the languages we have to update/create
+
+cd po || abort "couldn't change directory to po!"
+
+# This assumes that we won't have dirnames with space, which is
+# the case for language codes, which are the only subdirs we expect to
+# find in po/ anyway. If you put anything else there, you need to suffer
+# the consequences of your actions, so we don't do sanity checks
+langs=""
+
+for lang in * ; do
+ if test ! -d $lang; then
+ continue
+ fi
+ langs="$langs $lang"
+done
+
+# go back
+cd ..
+
+# First thing first, update the .pot template. We place it in the po/
+# directory at the top level. You a recent enough xgettext that supports
+# --package-name
+potfile=po/minetest.pot
+xgettext --package-name=minetest -F -n -o $potfile src/*.cpp src/*.h
+
+# Now iterate on all languages and create the po file if missing, or update it
+# if it exists already
+for lang in $langs ; do # note the missing quotes around $langs
+ pofile=po/$lang/minetest.po
+ if test -e $pofile; then
+ echo "[$lang]: updating strings"
+ msgmerge -F -U $pofile $potfile
+ else
+ # This will ask for the translator identity
+ echo "[$lang]: NEW strings"
+ msginit -l $lang -o $pofile -i $potfile
+ fi
+done
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262
/*
Minetest
Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program 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 Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#ifndef INVENTORYMANAGER_HEADER
#define INVENTORYMANAGER_HEADER

#include "inventory.h"
#include <iostream>
#include <string>
class ServerActiveObject;

struct InventoryLocation
{
	enum Type{
		UNDEFINED,
		CURRENT_PLAYER,
		PLAYER,
		NODEMETA,
        DETACHED,
	} type;

	std::string name; // PLAYER, DETACHED
	v3s16 p; // NODEMETA

	InventoryLocation()
	{
		setUndefined();
	}
	void setUndefined()
	{
		type = UNDEFINED;
	}
	void setCurrentPlayer()
	{
		type = CURRENT_PLAYER;
	}
	void setPlayer(const std::string &name_)
	{
		type = PLAYER;
		name = name_;
	}
	void setNodeMeta(v3s16 p_)
	{
		type = NODEMETA;
		p = p_;
	}
	void setDetached(const std::string &name_)
	{
		type = DETACHED;
		name = name_;
	}

	bool operator==(const InventoryLocation &other) const
	{
		if(type != other.type)
			return false;
		switch(type){
		case UNDEFINED:
			return false;
		case CURRENT_PLAYER:
			return true;
		case PLAYER:
			return (name == other.name);
		case NODEMETA:
			return (p == other.p);
		case DETACHED:
			return (name == other.name);
		}
		return false;