Lucky Language Inflections - 0.28.0

Customizing how Lucky works with languages


It is helpful to be able to configure your cli-tasks to work the same as lucky. In lucky you can configure the application’s behavior / settings in the config folder.

For example, Lucky by default will pluralize staff as staffs - which is ok if you are talking about shepherd staffs - but not employees.


As of Lucky 0.28.0 wordsmith works well with configuration - adding your own settings. You simple create an file in the config folder. Here is an example config:

# config/
# `staff` as in employees - not walking sticks:
Wordsmith::Inflector.inflections.irregular("person", "persons")

when we test our new lucky config with lucky exec:

lucky exec
# then when vim or nano opens you can enter something like:
require "../../src/"
include Lucky::TextHelpers
pp pluralize(2, "staff")
pp pluralize(2, "person")

you will get the expected:

"2 staff"
"2 persons"


However, currently, the settings is only used by the lucky application and not the lucky generators (gen.tasks) - which are pre-compiled. They are pre-compiled on install - BEFORE you even create a config file. Thus the generators generate files that are incompatible with Lucky’s configured behavior.

This is what happens - it generates staffs files and routes :(

lucky gen.resource.browser Staff name:String

Created CreateStaffs::V20210811201213 in ./db/migrations/
Generated Staff in ./src/models/
Generated SaveStaff in ./src/operations/
Generated DeleteStaff in ./src/operations/
Generated StaffQuery in ./src/queries/
Generated Staffs::Index in ./src/actions/staffs/
Generated Staffs::Show in ./src/actions/staffs/
Generated Staffs::New in ./src/actions/staffs/
Generated Staffs::Create in ./src/actions/staffs/
Generated Staffs::Edit in ./src/actions/staffs/
Generated Staffs::Update in ./src/actions/staffs/
Generated Staffs::Delete in ./src/actions/staffs/
Generated Staffs::IndexPage in ./src/pages/staffs/
Generated Staffs::ShowPage in ./src/pages/staffs/
Generated Staffs::NewPage in ./src/pages/staffs/
Generated Staffs::EditPage in ./src/pages/staffs/
Generated Staffs::FormFields in ./src/components/staffs/


(Lucky contributors are considering more elegant solutions)

With guidance from the lucky team we found a clumsy solution. Once we understood that the tasks were pre-compiled automatically. I was able to read how the script worked and noticed it responds to a skip pre-compile env_var and so we were able to solve it with the following procedure:

# clean up repo of gen.tasks that were problematic
# git clean -fd

# remove previously compiled shards
rm -rf lib && rm -rf bin

# after trashing all the shard - safest to be sure they are intact (or even updated)
SKIP_LUCKY_TASK_PRECOMPILATION=true shards install # or shards update

# re-run the setup

Now with the first task it will compile the task (a bit slow), but it uses your config file!

lucky gen.resource.browser Staff name:String

compiling ...

Now we finally get the expected results when we run the task!

Created CreateStaff::V20210812185142 in ./db/migrations/
Generated Staff in ./src/models/
Generated SaveStaff in ./src/operations/
Generated DeleteStaff in ./src/operations/
Generated StaffQuery in ./src/queries/
Generated Staff::Index in ./src/actions/staff/
Generated Staff::Show in ./src/actions/staff/
Generated Staff::New in ./src/actions/staff/
Generated Staff::Create in ./src/actions/staff/
Generated Staff::Edit in ./src/actions/staff/
Generated Staff::Update in ./src/actions/staff/
Generated Staff::Delete in ./src/actions/staff/
Generated Staff::IndexPage in ./src/pages/staff/
Generated Staff::ShowPage in ./src/pages/staff/
Generated Staff::NewPage in ./src/pages/staff/
Generated Staff::EditPage in ./src/pages/staff/
Generated Staff::FormFields in ./src/components/staff/
Bill Tihen
Bill Tihen
Developer, Data Enthusiast, Educator and Nature’s Friend

very curious – known to explore knownledge and nature