Plural support for "x more" messages, plus fixed those problems from last commit

This commit is contained in:
Julie Marchant 2019-06-10 01:08:01 -04:00
parent cc80af45ab
commit f205d7cc44
2 changed files with 93 additions and 16 deletions

View File

@ -17,6 +17,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <libintl.h>
#include "defs.h" #include "defs.h"
#include "structs.h" #include "structs.h"

View File

@ -634,25 +634,68 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
switch(type) switch(type)
{ {
case M_COLLECT: case M_COLLECT:
// FIXME: Add plural support
switch(id) switch(id)
{ {
case P_CASH: case P_CASH:
radio_getRandomMessage(fmt, _( radio_getRandomMessage(fmt, ngettext(
/// Info line messages for remaining cash to collect (singular)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Collect $%d more...\n" "Collect $%d more...\n"
"$%d more to go...")) "$%d more to collect...\n"
"Just $%d more needed...\n"
"Collect just $%d more...",
/// Info line messages for remaining cash to collect (plural)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Collect $%d more...\n"
"$%d more to collect...\n"
"$%d more needed...",
*targetValue));
sprintf(message, fmt, *targetValue); sprintf(message, fmt, *targetValue);
break; break;
case P_CARGO: case P_CARGO:
radio_getRandomMessage(fmt, _( radio_getRandomMessage(fmt, ngettext(
"Collect %d more...\n" /// Info line messages for remaining cargo pods to collect (singular)
"%d more to go...")) /// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Collect %d more cargo pod...\n"
"%d more cargo pod to collect...\n"
"%d more cargo pod needed...\n"
"Collect just %d more cargo pod...\n"
"Only %d cargo pod left to collect...",
/// Info line messages for remaining cargo pods to collect (plural)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Collect %d more cargo pods...\n"
"%d more cargo pods to collect...\n"
"%d more cargo pods needed...\n"
"Collect %d remaining cargo pods...",
*targetValue));
sprintf(message, fmt, *targetValue); sprintf(message, fmt, *targetValue);
break; break;
case P_ORE: case P_ORE:
radio_getRandomMessage(fmt, _( radio_getRandomMessage(fmt,ngettext(
"Collect %d more...\n" /// Info line messages for remaining ore to collect (singular)
"%d more to go...")) /// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Collect %d more piece of ore...\n"
"%d more piece of ore to collect...\n"
"%d more piece of ore needed...\n"
"Collect just %d more piece...",
/// Info line messages for remaining ore to collect (plural)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Collect %d more pieces of ore...\n"
"%d more pieces of ore to collect...\n"
"%d more pieces of ore needed...",
*targetValue));
sprintf(message, fmt, *targetValue); sprintf(message, fmt, *targetValue);
break; break;
} }
@ -706,16 +749,48 @@ static void mission_evaluate(int type, int id, int *completed, int *targetValue,
case M_DESTROY_TARGET_TYPE: case M_DESTROY_TARGET_TYPE:
if ((*targetValue <= 10) || (*targetValue % 10 == 0)) if ((*targetValue <= 10) || (*targetValue % 10 == 0))
{ {
// XXX: Plurals radio_getRandomMessage(fmt, ngettext(
radio_getRandomMessage(fmt, _( /// Info line messages for remaining enemies to destroy (singular)
"Destroy %d more...\n" /// This is a "\n"-separated list of possible choices to make. Please feel free
"%d more to go...")) /// to add as many as you like. Each entry must have one instance of "%d", which
sprintf(message, *fmt, *targetValue); /// is replaced with the number remaining.
"Destroy %d more target...\n"
"%d more target to destroy...\n"
"%d target remains...\n"
"Destroy just %d more...\n"
"Only %d target left...\n"
"Destroy %d last target...",
/// Info line messages for remaining enemies to destroy (plural)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Destroy %d more targets...\n"
"%d more targets to destroy...\n"
"%d targets remain...\n"
"Destroy %d remaining targets...",
*targetValue));
sprintf(message, fmt, *targetValue);
} }
break; break;
case M_DISABLE_TARGET: case M_DISABLE_TARGET:
// XXX: Plurals radio_getRandomMessage(fmt, ngettext(
sprintf(message, _("Disable %d more..."), *targetValue); /// Info line messages for remaining enemies to disable (singular)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Disable %d more target...\n"
"%d more target to disable...\n"
"Disable just %d more...\n"
"Disable %d last target...",
/// Info line messages for remaining enemies to disable (plural)
/// This is a "\n"-separated list of possible choices to make. Please feel free
/// to add as many as you like. Each entry must have one instance of "%d", which
/// is replaced with the number remaining.
"Disable %d more targets...\n"
"%d more targets to disable...\n"
"Disable %d remaining targets...",
*targetValue));
sprintf(message, fmt, *targetValue);
break; break;
} }