add en_CAT makefile and use ucfirst/ucwords

This commit is contained in:
Murphy 2024-04-05 15:00:27 -04:00
parent adc545a0cb
commit 4c8d58b646
Signed by: freya
GPG key ID: 744AB800E383AE52
19 changed files with 110 additions and 57 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
/data /data
/src/web/lang/en_CAT

View file

@ -11,7 +11,7 @@ class Modal_controller extends Controller {
* @param array $data * @param array $data
*/ */
private function modal($name, $data = array()): void { private function modal($name, $data = array()): void {
$title = lang($name . '_modal_title'); $title = ucwords(lang($name . '_modal_title'));
$data['title'] = $title; $data['title'] = $title;
$data['content'] = $name; $data['content'] = $name;
$this->view('template/modal', $data); $this->view('template/modal', $data);

View file

@ -7,7 +7,7 @@ class Auth_model extends Model {
public function get_data(): ?array { public function get_data(): ?array {
$data = parent::get_data(); $data = parent::get_data();
$data['title'] = lang('login'); $data['title'] = ucfirst(lang('login'));
return $data; return $data;
} }
} }

View file

@ -8,15 +8,15 @@ class Error_model extends Model {
private function get_msg(&$data) { private function get_msg(&$data) {
if (!array_key_exists('code', $_GET)) { if (!array_key_exists('code', $_GET)) {
http_response_code(500); http_response_code(500);
$data['msg'] = lang('error'); $data['msg'] = ucfirst(lang('error'));
$data['title'] = '500'; $data['title'] = '500';
} else { } else {
$code = $_GET['code']; $code = $_GET['code'];
http_response_code($code); http_response_code($code);
$data['title'] = $code; $data['title'] = $code;
$msg = lang('error_' . $code, FALSE); $msg = ucfirst(lang('error_' . $code, FALSE));
if (!$msg) { if (!$msg) {
$msg = lang('error'); $msg = ucfirst(lang('error'));
} }
$data['msg'] = $msg; $data['msg'] = $msg;
} }

View file

@ -15,7 +15,7 @@ class Home_model extends Model {
public function get_data(): ?array { public function get_data(): ?array {
$data = parent::get_data(); $data = parent::get_data();
$data['title'] = lang('title'); $data['title'] = ucfirst(lang('title'));
$data['posts'] = $this->get_posts(); $data['posts'] = $this->get_posts();
return $data; return $data;
} }

View file

@ -84,7 +84,7 @@ class People_model extends Model {
public function get_data(): ?array { public function get_data(): ?array {
$data = parent::get_data(); $data = parent::get_data();
$data['title'] = lang('title'); $data['title'] = ucfirst(lang('title'));
return $data; return $data;
} }
} }

View file

@ -59,7 +59,7 @@ class Profile_model extends Model {
$data['following'] = $following; $data['following'] = $following;
$data['followed'] = $followed; $data['followed'] = $followed;
$data['follow_id'] = $follow_id; $data['follow_id'] = $follow_id;
$data['title'] = lang('title', sub: [$user['first_name']]); $data['title'] = ucfirst(lang('title', sub: [$user['first_name']]));
return $data; return $data;
} }
} }

View file

@ -3,7 +3,7 @@
<div id="main-content"> <div id="main-content">
<div class="branding col"> <div class="branding col">
<h1>xssbook</h1> <h1>xssbook</h1>
<span><?=lang('login_branding')?></span> <span><?=ucfirst(lang('login_branding'))?></span>
</div> </div>
<div class="form card col"> <div class="form card col">
<form id="action-login" class="col" action=""> <form id="action-login" class="col" action="">
@ -13,9 +13,10 @@
name="username" name="username"
id="login-username" id="login-username"
placeholder=" " placeholder=" "
autofocus="true"
> >
<label for="username"> <label for="username">
<?=lang('ph_username')?> <?=ucfirst(lang('ph_username'))?>
</label> </label>
</div> </div>
<div class="rel mb"> <div class="rel mb">
@ -26,7 +27,7 @@
placeholder=" " placeholder=" "
> >
<label for="password"> <label for="password">
<?=lang('ph_password')?> <?=ucfirst(lang('ph_password'))?>
</label> </label>
</div> </div>
<?=ilang('action_login', <?=ilang('action_login',

View file

@ -2,5 +2,5 @@
<?php /* vi: syntax=php */ ?> <?php /* vi: syntax=php */ ?>
<div id="main-content"> <div id="main-content">
<h1><?=$title?></h1> <h1><?=$title?></h1>
<span><?=$msg?></span> <span><?=ucfirst($msg)?></span>
</div> </div>

View file

@ -9,9 +9,9 @@
id="action-new-post" id="action-new-post"
class="btn btn-alt btn-wide ml" class="btn btn-alt btn-wide ml"
autocomplete="off" autocomplete="off"
aria-label="<?=lang('action_new_post_tip')?>" aria-label="<?=ucfirst(lang('action_new_post_tip'))?>"
> >
<?=lang('action_new_post_text', sub: [$self['first_name']])?> <?=ucfirst(lang('action_new_post_text', sub: [$self['first_name']]))?>
</a> </a>
</div> </div>
<script> <script>

View file

@ -1,6 +1,6 @@
<?php /* Copyright (c) 2024 Freya Murphy */ ?> <?php /* Copyright (c) 2024 Freya Murphy */ ?>
<?php /* vi: syntax=php */ ?> <?php /* vi: syntax=php */ ?>
<div id="main-content" class="col"> <div id="main-content" class="col">
<h1 class="title"><?=lang('title')?></h1> <h1 class="title"><?=ucfirst(lang('title'))?></h1>
<h3 class="desc"><?=lang('desc')?></h3> <h3 class="desc"><?=ucfirst(lang('desc'))?></h3>
<hr> <hr>

View file

@ -12,9 +12,12 @@
<div class="row grow"> <div class="row grow">
<div class="col"> <div class="col">
<strong class="name"><?=$this->format_model->name($user)?></strong> <strong class="name"><?=$this->format_model->name($user)?></strong>
<span class="dim"><?=$user['follower_count'] . ' ' . lang('followers')?></span> <span class="dim"><?=$user['follower_count'] . ' ' . ucfirst(lang('followers'))?></span>
</div> </div>
<?php if (!isset($self) || $self['id'] != $user['id']): ?> <?php if (
$this->main->session &&
(!isset($self) || $self['id'] != $user['id'])
): ?>
<div id="follow-container"> <div id="follow-container">
<?=ilang( <?=ilang(
'action_follow', 'action_follow',
@ -120,7 +123,7 @@
</div> </div>
<?php if(strlen($user['profile_bio']) > 0): ?> <?php if(strlen($user['profile_bio']) > 0): ?>
<br> <br>
<strong><?=lang('bio')?></strong> <strong><?=ucfirst(lang('bio'))?></strong>
<span class="dim"><?=$user['profile_bio']?></span> <span class="dim"><?=$user['profile_bio']?></span>
<?php endif; ?> <?php endif; ?>
</div> </div>
@ -158,53 +161,53 @@
?> ?>
</div> </div>
<div id="tab-about" class="tab card"> <div id="tab-about" class="tab card">
<h1><?=lang('about_general')?></h1> <h1><?=ucfirst(lang('about_general'))?></h1>
<table> <table>
<tr> <tr>
<td><strong><?=lang('about_general_username')?></strong></td> <td><strong><?=ucfirst(lang('about_general_username'))?></strong></td>
<td><?=$user['username']?></td> <td><?=$user['username']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_general_full_name')?></strong></td> <td><strong><?=ucfirst(lang('about_general_full_name'))?></strong></td>
<td><?=$user['first_name'] . ' ' . $user['last_name']?></td> <td><?=$user['first_name'] . ' ' . $user['last_name']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_general_email')?></strong></td> <td><strong><?=ucfirst(lang('about_general_email'))?></strong></td>
<td><?=$user['email']?></td> <td><?=$user['email']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_general_gender')?></strong></td> <td><strong><?=ucfirst(lang('about_general_gender'))?></strong></td>
<td><?=$user['gender']?></td> <td><?=$user['gender']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_general_birth_date')?></strong></td> <td><strong><?=ucfirst(lang('about_general_birth_date'))?></strong></td>
<td><?=$user['birth_date']?></td> <td><?=$user['birth_date']?></td>
</tr> </tr>
</table> </table>
<h1><?=lang('about_stats')?></h1> <h1><?=ucfirst(lang('about_stats'))?></h1>
<table> <table>
<tr> <tr>
<td><strong><?=lang('about_stats_posts')?></strong></td> <td><strong><?=ucfirst(lang('about_stats_posts'))?></strong></td>
<td><?=$user['post_count']?></td> <td><?=$user['post_count']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_stats_like')?></strong></td> <td><strong><?=ucfirst(lang('about_stats_like'))?></strong></td>
<td><?=$user['like_count']?></td> <td><?=$user['like_count']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_stats_comments')?></strong></td> <td><strong><?=ucfirst(lang('about_stats_comments'))?></strong></td>
<td><?=$user['comment_count']?></td> <td><?=$user['comment_count']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_stats_following')?></strong></td> <td><strong><?=ucfirst(lang('about_stats_following'))?></strong></td>
<td><?=$user['followed_count']?></td> <td><?=$user['followed_count']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_stats_joined')?></strong></td> <td><strong><?=ucfirst(lang('about_stats_joined'))?></strong></td>
<td><?=$user['created']?></td> <td><?=$user['created']?></td>
</tr> </tr>
<tr> <tr>
<td><strong><?=lang('about_stats_seen')?></strong></td> <td><strong><?=ucfirst(lang('about_stats_seen'))?></strong></td>
<td><?=$user['seen']?></td> <td><?=$user['seen']?></td>
</tr> </tr>
</table> </table>

View file

@ -13,19 +13,19 @@
id="action-home" id="action-home"
class="btn<?=$this->main->info['app'] == 'home' ? ' btn-blue btn-border' : ''?>" class="btn<?=$this->main->info['app'] == 'home' ? ' btn-blue btn-border' : ''?>"
href="/home" href="/home"
title="<?=lang('action_home_tip')?>" title="<?=ucfirst(lang('action_home_tip'))?>"
> >
<i class="mi mi-lg">home</i> <i class="mi mi-lg">home</i>
<span><?=lang('action_home_text')?></span> <span><?=ucfirst(lang('action_home_text'))?></span>
</a> </a>
<a <a
id="action-people" id="action-people"
class="btn<?=$this->main->info['app'] == 'people' ? ' btn-blue btn-border' : ''?>" class="btn<?=$this->main->info['app'] == 'people' ? ' btn-blue btn-border' : ''?>"
href="/people" href="/people"
title="<?=lang('action_people_tip')?>" title="<?=ucfirst(lang('action_people_tip'))?>"
> >
<i class="mi mi-lg">people</i> <i class="mi mi-lg">people</i>
<span><?=lang('action_people_text')?></span> <span><?=ucfirst(lang('action_people_text'))?></span>
</a> </a>
<!--a <!--a
id="action-chat" id="action-chat"
@ -40,7 +40,7 @@
<div class="nav-right"> <div class="nav-right">
<button <button
id="action-hamburger" id="action-hamburger"
title="<?=lang('action_hamburger_tip')?>" title="<?=ucfirst(lang('action_hamburger_tip'))?>"
class="btn mr" class="btn mr"
> >
<i class="mi mi-lg">menu</i> <i class="mi mi-lg">menu</i>

View file

@ -9,14 +9,14 @@
<?=pfp($user)?> <?=pfp($user)?>
<div class="col ml"> <div class="col ml">
<strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong> <strong><?=$user['first_name'] . ' ' . $user['last_name']?></strong>
<span class="dim"><?=lang('now')?></span> <span class="dim"><?=ucfirst(lang('now'))?></span>
</div> </div>
</div> </div>
<textarea <textarea
type="text" type="text"
name="content" name="content"
id="new-post-content" id="new-post-content"
placeholder="<?=lang('action_new_post_text', sub: [$user['first_name']])?>" placeholder="<?=ucfirst(lang('action_new_post_text', sub: [$user['first_name']]))?>"
></textarea> ></textarea>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View file

@ -4,7 +4,7 @@
<form id="register-form"> <form id="register-form">
<div class="modal-content register-modal col"> <div class="modal-content register-modal col">
<label class="static"> <label class="static">
<?=lang('ph_basic_info')?> <?=ucwords(lang('ph_basic_info'))?>
</label> </label>
<div class="row mt"> <div class="row mt">
<div class="rel btn-wide"> <div class="rel btn-wide">
@ -15,7 +15,7 @@
placeholder=" " placeholder=" "
> >
<label for="first_name"> <label for="first_name">
<?=lang('ph_first_name')?> <?=ucwords(lang('ph_first_name'))?>
</label> </label>
</div> </div>
<div class="rel ml btn-wide"> <div class="rel ml btn-wide">
@ -26,7 +26,7 @@
placeholder=" " placeholder=" "
> >
<label for="last_name"> <label for="last_name">
<?=lang('ph_last_name')?> <?=ucwords(lang('ph_last_name'))?>
</label> </label>
</div> </div>
</div> </div>
@ -38,7 +38,7 @@
placeholder=" " placeholder=" "
> >
<label for="username"> <label for="username">
<?=lang('ph_username')?> <?=ucwords(lang('ph_username'))?>
</label> </label>
</div> </div>
<div class="rel mt"> <div class="rel mt">
@ -49,7 +49,7 @@
placeholder=" " placeholder=" "
> >
<label for="password"> <label for="password">
<?=lang('ph_password')?> <?=ucwords(lang('ph_password'))?>
</label> </label>
</div> </div>
<div class="rel mt"> <div class="rel mt">
@ -60,11 +60,11 @@
placeholder=" " placeholder=" "
> >
<label for="email"> <label for="email">
<?=lang('ph_email')?> <?=ucwords(lang('ph_email'))?>
</label> </label>
</div> </div>
<label for="birth_date" class="mt static"> <label for="birth_date" class="mt static">
<?=lang('ph_birth_date')?> <?=ucwords(lang('ph_birth_date'))?>
</label> </label>
<input <input
class="mt" class="mt"
@ -73,7 +73,7 @@
id="register-birth-date" id="register-birth-date"
> >
<label for="gender" class="mt static"> <label for="gender" class="mt static">
<?=lang('ph_gender')?> <?=ucwords(lang('ph_gender'))?>
</label> </label>
<div class="row mt" data-type="radio" data-name="gender-wrapper"> <div class="row mt" data-type="radio" data-name="gender-wrapper">
<div class="rel radio mr"> <div class="rel radio mr">
@ -81,13 +81,13 @@
type="radio" type="radio"
id="register-gender-male" id="register-gender-male"
name="gender" name="gender"
value="male" value="Male"
> >
<label <label
for="register-gender-male" for="register-gender-male"
class="static" class="static"
> >
<?=lang('ph_gender_male')?> <?=ucwords(lang('ph_gender_male'))?>
</label> </label>
</div> </div>
<div class="rel radio mr"> <div class="rel radio mr">
@ -95,13 +95,13 @@
type="radio" type="radio"
id="register-gender-female" id="register-gender-female"
name="gender" name="gender"
value="female" value="Female"
> >
<label <label
for="register-gender-female" for="register-gender-female"
class="static" class="static"
> >
<?=lang('ph_gender_female')?> <?=ucwords(lang('ph_gender_female'))?>
</label> </label>
</div> </div>
<div class="rel radio"> <div class="rel radio">
@ -109,13 +109,13 @@
type="radio" type="radio"
id="register-gender-lettuce" id="register-gender-lettuce"
name="gender" name="gender"
value="lettuce" value="Lettuce"
> >
<label <label
for="register-gender-lettuce" for="register-gender-lettuce"
class="static" class="static"
> >
<?=lang('ph_gender_lettuce')?> <?=ucwords(lang('ph_gender_lettuce'))?>
</label> </label>
</div> </div>
</div> </div>

View file

@ -21,7 +21,7 @@
$post_attrs['likeId'] = $post['like_id']; $post_attrs['likeId'] = $post['like_id'];
} }
?> ?>
<span class="likes dim"><span class="count"><?=$post['like_count']?></span><?=' ' . lang('likes')?></span> <span class="likes dim"><span class="count"><?=$post['like_count']?></span><?=' ' . ucfirst(lang('likes'))?></span>
<?php if ($self): ?> <?php if ($self): ?>
<hr> <hr>
<div class="row"> <div class="row">
@ -76,8 +76,8 @@
autocomplete="off" autocomplete="off"
type="text" type="text"
name="text" name="text"
placeholder="<?=lang('action_new_comment_text')?>" placeholder="<?=ucfirst(lang('action_new_comment_text'))?>"
aria-label="<?=lang('action_new_comment_tip')?>" aria-label="<?=ucfirst(lang('action_new_comment_tip'))?>"
> >
</form> </form>
</div> </div>

View file

@ -26,7 +26,7 @@ function ilang($key,
$sub = NULL, $sub = NULL,
$button = FALSE, $button = FALSE,
) { ) {
$text = lang($key . "_text", FALSE, sub: $sub); $text = ucfirst(lang($key . "_text", FALSE, sub: $sub));
$tip = lang($key . "_tip", FALSE, sub: $sub); $tip = lang($key . "_tip", FALSE, sub: $sub);
$icon = lang($key . "_icon", FALSE); $icon = lang($key . "_icon", FALSE);
$content = lang($key . "_content", FALSE); $content = lang($key . "_content", FALSE);

19
src/web/lang/Makefile Normal file
View file

@ -0,0 +1,19 @@
#
# en_CAT generator from en_US
# uwuify and awk required
#
LANG_SRC = $(shell find en_US -type f)
LANG_OBJ = $(patsubst en_US/%,en_CAT/%,$(LANG_SRC))
.PHONY: all
all: $(LANG_OBJ)
$(LANG_OBJ): en_CAT/% : en_US/%
@printf "\033[35m UWU \033[0m%s\n" $<
@mkdir -p $(@D)
@./_bin/transpile.sh $< $@
clean:
@rm -fr "en_CAT"

29
src/web/lang/_bin/transpile.sh Executable file
View file

@ -0,0 +1,29 @@
#!/bin/sh
lang_part() {
echo "$1" | awk "{split(\$0,a,\" = \"); print a[$2]}"
}
export -f lang_part
handle_line() {
line="$1"
left=$(lang_part "$line" 1)
right=$(lang_part "$line" 2)
echo "$left" | grep -Ev '_content|_line' > /dev/null
if [ "$?" -eq 0 ]; then
right=$(echo "$right" | uwuify)
fi;
right=${right%;};
echo "$left = $right;"
}
export -f handle_line
transpile() {
file="$1"
out="$2"
printf "" > "$out"
printf "<?php /* Copyright (c) 2024 Freya Murphy */\n\n" > "$out";
cat "$file" | grep '$lang' | xargs -d'\n' -I {} bash -c 'handle_line "$@"' _ {} >> "$out"
}
transpile "$1" "$2"