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

Formatter with plural forms #14

Open
pmudry opened this issue Feb 23, 2021 · 1 comment
Open

Formatter with plural forms #14

pmudry opened this issue Feb 23, 2021 · 1 comment

Comments

@pmudry
Copy link

pmudry commented Feb 23, 2021

I sometimes like to have the words minutes and seconds spelled correctly in the timer. Here is a working suggestions for plural forms (basic but working).

if string.match(text, "%%fm") then
	local minutes = math.floor(ms / 60000) % 60
	if minutes < 1 then
		minutes = string.format("%d", minutes) .. " minute"
	else
		minutes = string.format("%d", minutes) .. " minutes"
	end

	text = string.gsub(text, "%%fm", minutes)
end

if string.match(text, "%%fs") then
	local seconds = math.floor(ms / 1000) % 60
	if seconds < 1 then
		seconds = string.format("%d", seconds) .. " second"
	else
		seconds = string.format("%d", seconds) .. " seconds"
	end

	text = string.gsub(text, "%%fs", seconds)
end
@firstnevyn
Copy link

the logic needs work.
0 minute ? 1 minute 2 minutes
0 minutes remaining
s/</==/g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants