Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

content: updates 2024-10-25 #340

Merged
merged 8 commits into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@
</div>

<!-- Table -->
@if(tableOptions() && tableData().length>0){
@if(tableOptions() && countTotal>0){
<picsa-data-table [data]="tableData()" [options]="tableOptions()" [valueTemplates]="{created_at}">
<ng-template #created_at let-value> {{value | date: 'mediumDate' }} </ng-template>
</picsa-data-table>
} @else {
<picsa-loading style="margin: auto"></picsa-loading>
}

<!-- JSON Export -->
<button style="margin-top: 2rem; max-width: 200px" mat-button (click)="service.exportJson(tableData(),locale())">
Export JSON
</button>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,12 @@ export class TranslationsPageComponent {
/** ID of currently selected locale */
public locale = signal(LOCALES_DATA_HASHMAP.global_en.id);

/** Use subset of service translations to include non-archived */
private translations = computed(() => this.service.translations().filter((entry) => !entry.archived));

/** Generated list of table entries */
public tableData = computed(() => {
const translations = this.service.translations();
const translations = this.translations();
const locale = this.locale();
const data = this.generateTableData(locale, translations, this.includeTranslated());
return data;
Expand All @@ -58,13 +61,13 @@ export class TranslationsPageComponent {
/** List of entries pending translation */
public pendingEntries = computed(() => {
const locale = this.locale();
return this.service.translations().filter((entry) => !entry[locale]);
return this.translations().filter((entry) => !entry[locale]);
});

public translationProgress = computed(() => (100 * this.countTranslated) / this.countTotal);

public get countTotal() {
return this.service.translations().length;
return this.translations().length;
}
public get countPending() {
return this.pendingEntries().length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,20 @@ export class TranslationDashboardService extends PicsaAsyncService {
const { tool, context, text } = row;
return [tool, context, text].map((t) => t?.toLowerCase().replace(/[^a-z0-9]/g, '')).join('-');
}

/** WiP - method to export translations json used in app */
public exportJson(data: ITranslationRow[], locale: string) {
const json: Record<string, string> = {};
for (const { text, ...columns } of data) {
if (locale in columns) {
const translatedText = columns[locale] || '';
if (json[text] && json[text] !== translatedText) {
console.warn('Duplicate translation skipped', text, translatedText, json[translatedText]);
} else {
json[text] = translatedText;
}
}
}
console.log(locale, json);
}
}
133 changes: 71 additions & 62 deletions apps/picsa-server/supabase/data/translations_rows.csv

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const WEATHER_LINKS: Record<string, IResourceLink> = {
title: 'Weather Services ZM',
type: 'link',
subtype: 'whatsapp',
url: 'https://chat.whatsapp.com/KSRlJie2m3aKTz6urP8KuT',
url: 'https://chat.whatsapp.com/ElFe8iaYazGAO05Jrsdpc2',
cover: { image: 'assets/resources/covers/whatsapp.svg' },
filter: { countries: ['zm'] },
},
Expand Down
10 changes: 9 additions & 1 deletion libs/data/farmer_content/data/content/0_intro.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-marker';

import { IFarmerContent, IFarmerContentStep } from '../../types';
import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_VIDEO_TESTIMONIAL_DATA } from '@picsa/data/resources';
import {
PICSA_FARMER_VIDEOS_HASHMAP,
PICSA_VIDEO_TESTIMONIAL_DATA,
PICSA_OPERATIONAL_VIDEOS_HASHMAP,
} from '@picsa/data/resources';

const title = translateMarker('What is PICSA?');

Expand All @@ -22,6 +26,10 @@ const steps: IFarmerContent['steps'] = [
})
),
],
[
{ type: 'text', title: translateMarker('App') },
{ type: 'video', video: PICSA_OPERATIONAL_VIDEOS_HASHMAP.intro },
],
];

const content: Omit<IFarmerContent, 'id' | 'icon_path'> = {
Expand Down
6 changes: 5 additions & 1 deletion libs/data/farmer_content/data/content/2_climate_change.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-mark

import { IFarmerContent } from '../../types';
import { TOOLS_DATA_HASHMAP } from '../tools';
import { PICSA_FARMER_VIDEOS_HASHMAP } from '@picsa/data/resources';
import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_OPERATIONAL_VIDEOS_HASHMAP } from '@picsa/data/resources';

const title = translateMarker('What is happening to the climate in your area?');

Expand All @@ -17,6 +17,10 @@ const steps: IFarmerContent['steps'] = [
video: PICSA_FARMER_VIDEOS_HASHMAP.historic_climate,
},
],
[
{ type: 'text', title: translateMarker('Tool') },
{ type: 'video', video: PICSA_OPERATIONAL_VIDEOS_HASHMAP.historic_climate },
],
[
{
type: 'tool',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-mark

import { IFarmerContent } from '../../types';
import { TOOLS_DATA_HASHMAP } from '../tools';
import { PICSA_FARMER_VIDEOS_HASHMAP } from '@picsa/data/resources';
import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_OPERATIONAL_VIDEOS_HASHMAP } from '@picsa/data/resources';

const title = translateMarker('What changes can you make?');

Expand All @@ -17,6 +17,10 @@ const steps: IFarmerContent['steps'] = [
video: PICSA_FARMER_VIDEOS_HASHMAP.options,
},
],
[
{ type: 'text', title: translateMarker('Tool') },
{ type: 'video', video: PICSA_OPERATIONAL_VIDEOS_HASHMAP.options },
],
[
{
type: 'tool',
Expand Down
6 changes: 5 additions & 1 deletion libs/data/farmer_content/data/content/5_compare_options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { marker as translateMarker } from '@biesbjerg/ngx-translate-extract-mark

import { IFarmerContent } from '../../types';
import { TOOLS_DATA_HASHMAP } from '../tools';
import { PICSA_FARMER_VIDEOS_HASHMAP } from '@picsa/data/resources';
import { PICSA_FARMER_VIDEOS_HASHMAP, PICSA_OPERATIONAL_VIDEOS_HASHMAP } from '@picsa/data/resources';

const title = translateMarker('Are the changes a good idea?');

Expand All @@ -14,6 +14,10 @@ const steps: IFarmerContent['steps'] = [
video: PICSA_FARMER_VIDEOS_HASHMAP.participatory_budget,
},
],
[
{ type: 'text', title: translateMarker('Tool') },
{ type: 'video', video: PICSA_OPERATIONAL_VIDEOS_HASHMAP.participatory_budget },
],
[
{
type: 'tool',
Expand Down
3 changes: 2 additions & 1 deletion libs/data/resources/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export interface IPicsaVideo {
*/
locale_codes: ILocaleCode[];
size_kb: number;
resolution: '360p';
/** Generally 360p preferred but 480p used for operational videos */
resolution: '360p' | '480p';
supabase_url: string;
}

Expand Down
6 changes: 5 additions & 1 deletion libs/data/resources/videos/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { arrayToHashmap } from '@picsa/utils';
import { PICSA_OPERATIONAL_VIDEOS_DATA } from './operational';
import { PICSA_FARMER_VIDEOS_DATA } from './picsaSteps';
import { PICSA_VIDEO_TESTIMONIAL_DATA } from './testimonials';
import { hackGenerateLegacyResources } from './utils';
Expand All @@ -9,13 +10,16 @@ import { hackGenerateLegacyResources } from './utils';
*
* TODO - migrate all resources to use modern format so code below can be removed
***************************************************************************/

const operational = hackGenerateLegacyResources(PICSA_OPERATIONAL_VIDEOS_DATA);
const steps = hackGenerateLegacyResources(PICSA_FARMER_VIDEOS_DATA);
const testimonials = hackGenerateLegacyResources(PICSA_VIDEO_TESTIMONIAL_DATA);

export const RESOURCE_VIDEO_HASHMAP = {
...arrayToHashmap(operational, 'id'),
...arrayToHashmap(steps, 'id'),
...arrayToHashmap(testimonials, 'id'),
};

export * from './operational';
export * from './picsaSteps';
export * from './testimonials';
78 changes: 78 additions & 0 deletions libs/data/resources/videos/operational.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
import { arrayToHashmap } from '@picsa/utils';
import { IPicsaVideoData } from '../types';

type IPicsaOperationalVideoID = 'intro' | 'historic_climate' | 'options' | 'participatory_budget';

const PICSA_OPERATIONAL_VIDEOS_BASE: Record<IPicsaOperationalVideoID, Omit<IPicsaVideoData, 'id'>> = {
intro: {
children: [
{
id: '',
// HACK - zm_ny shown for all while waiting on other videos
locale_codes: ['zm_ny', 'global_en'],
resolution: '480p',
size_kb: 22300,
supabase_url:
'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/operational/overall.mp4',
},
],
},

historic_climate: {
children: [
{
id: '',
// HACK - zm_ny shown for all while waiting on other videos
locale_codes: ['zm_ny', 'global_en'],
size_kb: 15730,
resolution: '480p',
supabase_url:
'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/operational/historic-climate.mp4',
},
],
},

options: {
children: [
{
id: '',
// HACK - zm_ny shown for all while waiting on other videos
locale_codes: ['zm_ny', 'global_en'],
size_kb: 43900,
resolution: '480p',
supabase_url:
'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/operational/option.mp4',
},
],
},
participatory_budget: {
children: [
{
id: '',
// HACK - zm_ny shown for all while waiting on other videos
locale_codes: ['zm_ny', 'global_en'],
size_kb: 43410,
resolution: '480p',
supabase_url: 'https://wpctacqpzxfzlucblowh.supabase.co/storage/v1/object/public/zm/videos/operational/pb.mp4',
},
],
},
};

export const PICSA_OPERATIONAL_VIDEOS_DATA: IPicsaVideoData[] = Object.entries(PICSA_OPERATIONAL_VIDEOS_BASE).map(
([id, entry]) => ({
id: id as IPicsaOperationalVideoID,
children: entry.children.map((child) => {
const { locale_codes, resolution } = child;
// use primary locale code for id
const [locale_code] = locale_codes;
child.id = `operational_${id}_${locale_code}_${resolution}`;
return child;
}),
})
);

export const PICSA_OPERATIONAL_VIDEOS_HASHMAP: Record<IPicsaOperationalVideoID, IPicsaVideoData> = arrayToHashmap(
PICSA_OPERATIONAL_VIDEOS_DATA,
'id'
);
19 changes: 8 additions & 11 deletions libs/i18n/assets/debug.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
"Add Male Member": "•Add Male Member•",
"Add Option": "•Add Option•",
"Add Photo": "•Add Photo•",
"Additional": "•Additional•",
"afforestation": "•afforestation•",
"After the season": "•After the season•",
"All Submitted": "•All Submitted•",
"Analyse": "•Analyse•",
"and": "•and•",
"Annual Forecast": "•Annual Forecast•",
"Apply Fertiliser": "•Apply Fertiliser•",
"apply fertiliser": "•apply fertiliser•",
"apply pesticide": "•apply pesticide•",
Expand Down Expand Up @@ -42,7 +42,6 @@
"Budget Tool": "•Budget Tool•",
"build housing": "•build housing•",
"Calculated with the date range of Start of rains and End of the rains": "•Calculated with the date range of Start of rains and End of the rains•",
"Calendar": "•Calendar•",
"Calendar name": "•Calendar name•",
"Calendar Time": "•Calendar Time•",
"Cancel": "•Cancel•",
Expand All @@ -68,14 +67,12 @@
"Comparing different options and planning using Participatory Budgets": "•Comparing different options and planning using Participatory Budgets•",
"compost manure making": "•compost manure making•",
"consumed": "•consumed•",
"Consumed": "•Consumed•",
"Copy": "•Copy•",
"Cost": "•Cost•",
"Cotton": "•Cotton•",
"Cowpeas": "•Cowpeas•",
"cowpeas": "•cowpeas•",
"Create": "•Create•",
"Create Calendar": "•Create Calendar•",
"Create New": "•Create New•",
"Create New Budget": "•Create New Budget•",
"Crop": "•Crop•",
Expand All @@ -100,7 +97,7 @@
"Download All": "•Download All•",
"Download the PICSA Manual": "•Download the PICSA Manual•",
"Downloaded": "•Downloaded•",
"Downscaled Forecast": "•Downscaled Forecast•",
"Downscaled Forecasts": "•Downscaled Forecasts•",
"Draw Here": "•Draw Here•",
"ducks": "•ducks•",
"During the season": "•During the season•",
Expand Down Expand Up @@ -137,6 +134,7 @@
"fodder for livestock": "•fodder for livestock•",
"For Sale": "•For Sale•",
"Forecast": "•Forecast•",
"Forecasts": "•Forecasts•",
"Forms": "•Forms•",
"Frequency of Extreme": "•Frequency of Extreme•",
"Fri": "•Fri•",
Expand All @@ -152,6 +150,7 @@
"Here we can see information for a specific crop variety": "•Here we can see information for a specific crop variety•",
"High": "•High•",
"Historic climate": "•Historic climate•",
"Home": "•Home•",
"hours": "•hours•",
"housing": "•housing•",
"How long is your budget for?": "•How long is your budget for?•",
Expand All @@ -163,7 +162,6 @@
"Increase Scale": "•Increase Scale•",
"Input at least 3 letters to search": "•Input at least 3 letters to search•",
"Inputs": "•Inputs•",
"Intro": "•Intro•",
"Introduction": "•Introduction•",
"Investment": "•Investment•",
"Investment in terms of money and time": "•Investment in terms of money and time•",
Expand Down Expand Up @@ -226,8 +224,8 @@
"Neutral": "•Neutral•",
"New Budget": "•New Budget•",
"New Profile": "•New Profile•",
"next": "•next•",
"Next": "•Next•",
"No outputs produce for consumption": "•No outputs produce for consumption•",
"No photos added": "•No photos added•",
"No results found": "•No results found•",
"No saved calendars": "•No saved calendars•",
Expand Down Expand Up @@ -264,6 +262,7 @@
"pot for storage": "•pot for storage•",
"Potatoes": "•Potatoes•",
"Practice": "•Practice•",
"previous": "•previous•",
"Print Version": "•Print Version•",
"Privacy Policy": "•Privacy Policy•",
"Probability": "•Probability•",
Expand All @@ -278,7 +277,6 @@
"Purchased": "•Purchased•",
"Quantity": "•Quantity•",
"Rain": "•Rain•",
"Ram": "•Ram•",
"Records": "•Records•",
"Redo": "•Redo•",
"Reload": "•Reload•",
Expand Down Expand Up @@ -307,6 +305,7 @@
"Season Crops": "•Season Crops•",
"Seasonal Calendar": "•Seasonal Calendar•",
"Seasonal forecast": "•Seasonal forecast•",
"Seasonal Forecast": "•Seasonal Forecast•",
"Seasonal Rainfall": "•Seasonal Rainfall•",
"Seasonal rainfall is defined as the total rain recorded from the start of the season until the end of the season": "•Seasonal rainfall is defined as the total rain recorded from the start of the season until the end of the season•",
"Seasonal Total Rainfall (mm)": "•Seasonal Total Rainfall (mm)•",
Expand Down Expand Up @@ -366,7 +365,6 @@
"sweet potatoes": "•sweet potatoes•",
"Switch to Extension": "•Switch to Extension•",
"Switch to Farmer": "•Switch to Farmer•",
"Take App Tour": "•Take App Tour•",
"Terciles": "•Terciles•",
"Testimonials": "•Testimonials•",
"The crop filter shows more information for specific crops": "•The crop filter shows more information for specific crops•",
Expand All @@ -388,9 +386,8 @@
"Tools": "•Tools•",
"tools": "•tools•",
"Total": "•Total•",
"Total Consumed": "•Total Consumed•",
"Total Produced": "•Total Produced•",
"tractor hire": "•tractor hire•",
"Training": "•Training•",
"transport": "•transport•",
"transport livestock": "•transport livestock•",
"transportation hire": "•transportation hire•",
Expand Down
Loading
Loading